-
Notifications
You must be signed in to change notification settings - Fork 3.7k
73 lines (67 loc) · 2.97 KB
/
batch_release_pr.yml
File metadata and controls
73 lines (67 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: "Creates Batch Release for a Package"
on:
repository_dispatch:
types: [batch-release-pr]
env:
HEAD_BRANCH_NAME: ${{ github.event.client_payload.package }}-${{ github.run_id }}-${{ github.run_attempt }}
jobs:
create_batch_release_branch:
runs-on: ubuntu-latest
permissions:
contents: write # Grants write permission to create a branch.
outputs:
head_branch_created: ${{ steps.check-branch-exists.outputs.exists }}
release_branch: ${{ steps.create-branch.outputs.release_branch }} # e.g. release-go_router-17.2.2, returned by branches-for-batch-release tool.
env:
GITHUB_TOKEN: ${{ secrets.FLUTTERGITHUBBOT_TOKEN }}
steps:
- name: checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
token: ${{ secrets.FLUTTERGITHUBBOT_TOKEN }}
- 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 branches for a batch release
# Branches 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
id: create-branch
run: |
git config --global user.name "flutteractionsbot"
git config --global user.email "fluttergithubbot@gmail.com"
dart ./script/tool/lib/src/main.dart branches-for-batch-release --packages=${GITHUB_EVENT_CLIENT_PAYLOAD_PACKAGE} --branch=${HEAD_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/${HEAD_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.head_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:
GITHUB_TOKEN: ${{ secrets.FLUTTERGITHUBBOT_TOKEN }}
steps:
- name: checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ env.HEAD_BRANCH_NAME }}
- name: Create batch release PR
run: |
gh pr create \
--base "${{ needs.create_batch_release_branch.outputs.release_branch }}" \
--head "${{ env.HEAD_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 }}\`."