-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
64 lines (56 loc) · 2.16 KB
/
cron.yml
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
name: Cron
on:
schedule:
- cron: '0 7 * * *' # daily, 7am
workflow_dispatch:
permissions:
contents: read
jobs:
trigger-ci:
permissions:
contents: read # the push uses a non-default token so it will trigger workflows
checks: read
name: Trigger cron build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch:
- main
- beta
- release
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
ref: ${{matrix.branch}}
- name: Make a commit to have a unique sha
run: |
touch cron.txt
git config --local user.email 'cron@example.com'
git config --local user.name 'Ember.js Cron CI'
git add cron.txt
git commit -m "Cron $(date +%Y-%m-%d) for ${{matrix.branch}}"
export SHA=`git rev-parse HEAD`
echo "SHA=$SHA" >> $GITHUB_ENV
- name: Push branch to trigger Build workflow
# This must use a personal access token because of a Github Actions
# limitation where it will not trigger workflows from pushes from
# other workflows with the token it provides.
# The PERSONAL_ACCESS secret must be a token with `repo` scope.
# See https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
run: |
git checkout -B cron-${{matrix.branch}}-${{env.SHA}}
git push https://${GITHUB_ACTOR}:${{ secrets.PERSONAL_TOKEN }}@github.com/${GITHUB_REPOSITORY} cron-${{matrix.branch}}-${{env.SHA}} --force
- name: Wait for Build completion
uses: jitterbit/await-check-suites@v1
with:
ref: ${{ env.SHA }}
appSlugFilter: github-actions
onlyFirstCheckSuite: true
timeoutSeconds: 1800
- name: Cleanup
# Always cleanup the cron-* branches
if: always()
run: git push https://${GITHUB_ACTOR}:${{ secrets.PERSONAL_TOKEN}}@github.com/${GITHUB_REPOSITORY} --delete cron-${{matrix.branch}}-${{env.SHA}} || true # Don't fail build if cleanup fails