batch-release-pr #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Creates Batch Release for a Package" | |
| on: | |
| repository_dispatch: | |
| types: [batch-release-pr] | |
| jobs: | |
| create_batch_release_branch: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Grants write permission to create a branch. | |
| env: | |
| BRANCH_NAME: ${{ github.event.client_payload.package }}-${{ github.run_id }}-${{ github.run_attempt }} | |
| outputs: | |
| branch_created: ${{ steps.check-branch-exists.outputs.exists }} | |
| steps: | |
| - name: checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: "Install Flutter" | |
| uses: ./.github/workflows/internals/install_flutter | |
| - name: Set up tools | |
| run: dart pub get | |
| working-directory: ${{ github.workspace }}/script/tool | |
| # This step is to create a branch for batch release | |
| # A branch may not be created if there is nothing to release. | |
| # In that case, the workflow will exit and complete successfully. | |
| - name: create batch release branch | |
| run: | | |
| git config --global user.name "flutteractionsbot" | |
| git config --global user.email "fluttergithubbot@gmail.com" | |
| dart ./script/tool/lib/src/main.dart branch-for-batch-release --packages=${GITHUB_EVENT_CLIENT_PAYLOAD_PACKAGE} --branch=${BRANCH_NAME} --remote=origin | |
| env: | |
| GITHUB_EVENT_CLIENT_PAYLOAD_PACKAGE: ${{ github.event.client_payload.package }} | |
| - name: Check if branch was created | |
| id: check-branch-exists | |
| run: | | |
| if git show-ref --verify --quiet refs/heads/${BRANCH_NAME}; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| create_release_pr: | |
| needs: create_batch_release_branch | |
| if: needs.create_batch_release_branch.outputs.branch_created == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| # The create-pull-request action needs both content and pull-requests permissions. | |
| pull-requests: write | |
| contents: write | |
| env: | |
| BRANCH_NAME: ${{ github.event.client_payload.package }}-${{ github.run_id }}-${{ github.run_attempt }} | |
| steps: | |
| - name: checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| ref: ${{ env.BRANCH_NAME }} | |
| - name: Create batch release PR | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.FLUTTERGITHUBBOT_TOKEN }} | |
| run: | | |
| gh pr create \ | |
| --base "release-${{ github.event.client_payload.package }}" \ | |
| --head "${{ env.BRANCH_NAME }}" \ | |
| --title "[${{ github.event.client_payload.package }}] Batch release" \ | |
| --body "This PR was created automatically to batch release the \`${{ github.event.client_payload.package }}\`." | |