Skip to content

Commit f72870a

Browse files
Fix GitHub workflows to use the flutteractionsbot mirror for PR branches. (flutter#183470)
Branch creation is restricted in `flutter/flutter` and so GitHub workflows can't (by default) create any branches on the main repository. However, the `easy_cp` workflow already works around this by using the `flutteractionsbot` mirror to host the PR branches. This PR modifies our workflows to make them in line with the strategy that `easy_cp` uses.
1 parent 3c16f55 commit f72870a

3 files changed

Lines changed: 59 additions & 27 deletions

File tree

.github/workflows/merge-changelog.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,25 @@ jobs:
1919
- name: Setup Repository
2020
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2121
with:
22+
repository: flutteractionsbot/flutter
23+
token: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
2224
ref: master
2325

24-
# avoid downloading hundreds of other branches/history
25-
# utilizing `fetch-depth:0` in actions/checkout would clone everything.
26-
- name: Fetch Stable Branch Only
27-
run: git fetch origin stable:stable --depth=1
28-
2926
- name: Configure git
3027
run: |
31-
git config user.name "[bot] Merge Changelog"
28+
git config user.name "GitHub Actions Bot"
3229
git config user.email "<>"
30+
git remote add upstream https://github.com/flutter/flutter.git
31+
32+
# avoid downloading hundreds of other branches/history
33+
# utilizing `fetch-depth:0` in actions/checkout would clone everything.
34+
- name: Fetch Stable Branch Only
35+
run: git fetch upstream stable:stable --depth=1
3336

3437
- name: Read CHANGELOG.md from the stable branch
3538
id: read_stable_changelog
3639
run: |
37-
# origin/stable is locally mapped to stable
40+
# upstream/stable is locally mapped to stable
3841
# use the local stable ref from above
3942
CHANGELOG_CONTENT=$(git show stable:CHANGELOG.md)
4043
echo "CHANGELOG_CONTENT<<EOF" >> $GITHUB_ENV
@@ -43,6 +46,8 @@ jobs:
4346
4447
- name: Prepare PR branch and commit changes
4548
id: prepare_pr_branch
49+
env:
50+
GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
4651
run: |
4752
PR_BRANCH="sync-changelog-stable-to-master-$(date +%s)"
4853
echo "pr_branch_name=$PR_BRANCH" >> "$GITHUB_OUTPUT"
@@ -54,13 +59,14 @@ jobs:
5459
5560
- name: Create Pull Request
5661
env:
57-
GH_TOKEN: ${{ github.token }}
62+
GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
5863
run: |
5964
PR_HEAD_BRANCH=${{ steps.prepare_pr_branch.outputs.pr_branch_name }}
6065
6166
gh pr create \
6267
--base master \
63-
--head "$PR_HEAD_BRANCH" \
68+
--head flutteractionsbot:$PR_HEAD_BRANCH \
69+
--repo flutter/flutter \
6470
--title "Sync CHANGELOG.md from stable" \
6571
--body "This PR automates the synchronization of \`CHANGELOG.md\` from the \`stable\` branch to the \`master\` branch." \
6672
--label autosubmit

.github/workflows/roll-dart-dependencies.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ jobs:
1818
steps:
1919
- name: Checkout Repository
2020
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
21+
with:
22+
repository: flutteractionsbot/flutter
23+
token: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
24+
ref: master
25+
26+
- name: Configure git
27+
env:
28+
GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
29+
run: |
30+
git config user.name "GitHub Actions Bot"
31+
git config user.email "<>"
32+
git remote add upstream https://github.com/flutter/flutter.git
33+
git fetch upstream ${{ github.ref_name }}
34+
35+
BRANCH_NAME="sync-dart-${{ inputs.dart_hash }}"
36+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
37+
38+
git checkout -b "$BRANCH_NAME" upstream/${{ github.ref_name }}
2139
2240
- name: Download and Decode Dart DEPS
2341
id: download-deps
@@ -78,20 +96,15 @@ jobs:
7896
- name: Create PR if Changed
7997
if: steps.git-check.outputs.changed == 'true'
8098
env:
81-
GH_TOKEN: ${{ github.token }}
99+
GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
82100
run: |
83-
git config user.name "[bot] Update Dart Dependencies"
84-
git config user.email "<>"
85-
86-
BRANCH_NAME="sync-dart-${{ inputs.dart_hash }}"
87-
88-
git checkout -b "$BRANCH_NAME"
89101
git add DEPS
90-
git commit -m "Update flutter DEPS to dart $DART_HASH"
102+
git commit -m "Update flutter DEPS to dart ${{ inputs.dart_hash }}"
91103
git push origin "$BRANCH_NAME" --force
92104
93105
gh pr create \
94106
--title "[${{ github.ref_name }}] Update Flutter DEPS to Dart ${{ inputs.dart_hash }}" \
95107
--body "This PR updates the transitive dependencies in the engine \`DEPS\` file based on Dart SDK hash \`${{ inputs.dart_hash }}\`." \
108+
--repo flutter/flutter \
96109
--base ${{ github.ref_name }} \
97-
--head "$BRANCH_NAME"
110+
--head flutteractionsbot:$BRANCH_NAME

.github/workflows/sync-engine-version.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ jobs:
1313
steps:
1414
- name: Checkout Repository
1515
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
16+
with:
17+
repository: flutteractionsbot/flutter
18+
token: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
19+
ref: master
20+
21+
- name: Configure git
22+
env:
23+
GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
24+
run: |
25+
git config user.name "GitHub Actions Bot"
26+
git config user.email "<>"
27+
git remote add upstream https://github.com/flutter/flutter.git
28+
git fetch upstream ${{ github.ref_name }}
29+
30+
BRANCH_NAME="update-engine-$(date +%s)"
31+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
32+
33+
git checkout -b "$BRANCH_NAME" upstream/${{ github.ref_name }}
1634
1735
- name: Generate and Capture Hash
1836
id: generate-hash
@@ -47,15 +65,9 @@ jobs:
4765
- name: Create PR if Changed
4866
if: steps.git-check.outputs.changed == 'true'
4967
env:
50-
GH_TOKEN: ${{ github.token }}
68+
GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
5169
run: |
52-
# Configure Git
53-
git config user.name "[bot] Sync Engine Version"
54-
git config user.email "<>"
55-
56-
# Create and push a unique branch
57-
BRANCH_NAME="update-engine-$(date +%s)"
58-
git checkout -b "$BRANCH_NAME"
70+
# Make a commit and push to the branch.
5971
git add bin/internal/engine.version
6072
git commit -m "Update engine.version to $(cat bin/internal/engine.version)"
6173
git push origin "$BRANCH_NAME"
@@ -64,5 +76,6 @@ jobs:
6476
gh pr create \
6577
--title "[${{ github.ref_name }}] Sync engine.version to ${{ env.ENGINE_HASH }}" \
6678
--body "Updates the engine.version file." \
79+
--repo flutter/flutter \
6780
--base ${{ github.ref_name }} \
68-
--head "$BRANCH_NAME"
81+
--head flutteractionsbot:$BRANCH_NAME

0 commit comments

Comments
 (0)