forked from flutter/devtools
-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (57 loc) · 2.23 KB
/
flutter-candidate-update.yaml
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: Flutter Candidate Update
on:
workflow_dispatch: # Allows for manual triggering if needed
# TODO(https://github.com/flutter/devtools/issues/7939): Re-enable once Flutter candidates
# are tagged again.
# schedule:
# # * is a special character in YAML so you have to quote this string
# - cron: "0 8/12 * * *" # Run every day at midnight and noon Pacific Time
permissions:
contents: write
pull-requests: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
update-candidate:
if: ${{ github.repository == 'flutter/devtools' }}
name: Update Flutter Candidate Version
runs-on: ubuntu-latest
steps:
- name: git clone devtools
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
with:
ref: master
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- name: setup git config
run: |
git config user.name "DevTools Workflow Bot"
git config user.email "[email protected]"
- name: get the latest flutter candidate
run: |
set -ex
pushd tool/
dart pub get
popd
tool/latest_flutter_candidate.sh | sed 's|refs/tags/||' > flutter-candidate.txt
- name: Create the PR
run: |
set -ex
if ! [[ `git status --porcelain --untracked-files=no` ]]; then
# No changes made, so we can just exit.
echo "No change to the flutter-candidate.txt file"
exit
fi
COMMIT_MESSAGE="Changing Flutter Candidate to $(cat flutter-candidate.txt)"
BRANCH_NAME="auto-candidate-$(date +%s)"
# Stage the file, commit and push
git checkout -b "$BRANCH_NAME"
git add .
git commit -m "$COMMIT_MESSAGE"
git push -u origin "$BRANCH_NAME"
PR_URL=$(gh pr create --title "$COMMIT_MESSAGE" --body "Automated Flutter candidate version bump.")
# Change github credentials back to the actions bot.
GH_TOKEN="$ORIGINAL_GH_TOKEN"
gh pr edit $PR_URL --add-label "autosubmit"
env:
GH_TOKEN: ${{ secrets.DEVTOOLS_WORKFLOW_BOT_TOKEN }}
ORIGINAL_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}