forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (74 loc) · 3.29 KB
/
sync-engine-version.yml
File metadata and controls
89 lines (74 loc) · 3.29 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Sync Engine Version
on:
workflow_dispatch:
jobs:
sync-engine:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
repository: flutteractionsbot/flutter
token: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
ref: master
- name: Configure git
env:
GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
run: |
git config user.name "flutteractionsbot"
git config user.email "<flutter-actions-bot@google.com>"
git remote add upstream https://github.com/flutter/flutter.git
git fetch upstream ${{ github.ref_name }}
BRANCH_NAME="update-engine-$(date +%s)"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
git checkout -b "$BRANCH_NAME" upstream/${{ github.ref_name }}
- name: Generate and Capture Hash
id: generate-hash
run: |
# Capture the OLD hash (handle case where file doesn't exist)
if [ -f bin/internal/engine.version ]; then
OLD_HASH=$(< bin/internal/engine.version)
else
OLD_HASH="None (New File)"
fi
echo "OLD_HASH=$OLD_HASH" >> $GITHUB_ENV
chmod +x bin/internal/last_engine_commit.sh
NEW_HASH=$(./bin/internal/last_engine_commit.sh)
echo "$NEW_HASH" > bin/internal/engine.version
echo "ENGINE_HASH=$NEW_HASH" >> $GITHUB_ENV
- name: Check for Changes
id: git-check
run: |
# -N (intent-to-add) treats untracked files as existing but empty
# -f adds even if it's in the .gitignore (which it usually is)
git add -N -f bin/internal/engine.version
if git diff --cached --exit-code bin/internal/engine.version; then
echo "changed=false" >> $GITHUB_OUTPUT
# Nice big No-Op Summary
echo "## ✅ Engine version already up to date" >> $GITHUB_STEP_SUMMARY
echo "The engine is already at hash \`${{ env.ENGINE_HASH }}\`. No PR was created." >> $GITHUB_STEP_SUMMARY
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Create PR if Changed
if: steps.git-check.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
run: |
git commit -m "Update engine.version to ${{ env.ENGINE_HASH }}"
git push origin "$BRANCH_NAME"
# Capture the PR URL
PR_URL=$(gh pr create \
--title "[${{ github.ref_name }}] Sync engine.version to ${{ env.ENGINE_HASH }}" \
--body "Updates the engine.version file from \`${{ env.OLD_HASH }}\` to \`${{ env.ENGINE_HASH }}\`." \
--repo flutter/flutter \
--base ${{ github.ref_name }} \
--head flutteractionsbot:$BRANCH_NAME)
# Nice big PR Success Summary
echo "## 🚀 PR Created Successfully" >> $GITHUB_STEP_SUMMARY
echo "Updated engine version from \`${{ env.OLD_HASH }}\` to \`${{ env.ENGINE_HASH }}\`." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "🔗 **View Pull Request:** $PR_URL" >> $GITHUB_STEP_SUMMARY