|
| 1 | +name: automated-release-tasks |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + # Cron syntax is "minute[0-59] hour[0-23] date[1-31] month[1-12] day[0-6]". '*' is 'any value,' and multiple values |
| 5 | + # can be specified with comma-separated lists. All times are UTC. |
| 6 | + # So this expression means "run at 12 PM UTC, every Friday". |
| 7 | + - cron: "0 12 * * 5" |
| 8 | + |
| 9 | + |
| 10 | +jobs: |
| 11 | + # Depending on circumstances, we may want to exit early instead of running the workflow to completion. |
| 12 | + verify-should-run: |
| 13 | + runs-on: macos-latest |
| 14 | + outputs: |
| 15 | + should-run: ${{ steps.main.outputs.should_run }} |
| 16 | + steps: |
| 17 | + - id: main |
| 18 | + run: | |
| 19 | + # `date -u` returns UTC datetime, and `%u` formats the output to be the day of the week, with 1 being Monday, |
| 20 | + # 2 being Tuesday, etc. |
| 21 | + TODAY_DOW=$(date -u +%u) |
| 22 | + # This `date` expression returns the last Tuesday of the month, which is our Release Day. %d formats the output |
| 23 | + # as the day of the month (1-31). |
| 24 | + NEXT_RELEASE_DATE=$(date -u -v1d -v+1m -v-1d -v-tue +%d) |
| 25 | + # This `date` expression returns next Tuesday, and `%d` formats the output as the day of the month (1-31). |
| 26 | + NEXT_TUESDAY_DATE=$(date -u -v+tue +%d) |
| 27 | + # This workflow should only be allowed to run to completion on the Friday before Release Day. |
| 28 | + [[ $TODAY_DOW != 5 || $NEXT_RELEASE_DATE != $NEXT_TUESDAY_DATE ]] && echo "should_run=false" >> "$GITHUB_OUTPUT" || echo "should_run=true" >> "$GITHUB_OUTPUT" |
| 29 | + create-alpha-release-branch: |
| 30 | + runs-on: macos-latest |
| 31 | + needs: verify-should-run |
| 32 | + if: ${{ needs.verify-should-run.outputs.should-run == 'true' }} |
| 33 | + steps: |
| 34 | + - name: Invoke alpha workflow |
| 35 | + uses: actions/github-script@v6 |
| 36 | + with: |
| 37 | + github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} |
| 38 | + script: | |
| 39 | + await github.rest.actions.createWorkflowDispatch({ |
| 40 | + owner: context.repo.owner, |
| 41 | + repo: context.repo.repo, |
| 42 | + workflow_id: 'create-release-branch.yml', |
| 43 | + ref: 'dev-5' |
| 44 | + }); |
| 45 | + create-release-branch: |
| 46 | + runs-on: macos-latest |
| 47 | + needs: verify-should-run |
| 48 | + if: ${{ needs.verify-should-run.outputs.should-run == 'true' }} |
| 49 | + steps: |
| 50 | + - name: Invoke GA workflow |
| 51 | + uses: actions/github-script@v6 |
| 52 | + with: |
| 53 | + github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} |
| 54 | + script: | |
| 55 | + await github.rest.actions.createWorkflowDispatch({ |
| 56 | + owner: context.repo.owner, |
| 57 | + repo: context.repo.repo, |
| 58 | + workflow_id: 'create-release-branch.yml', |
| 59 | + ref: 'dev', |
| 60 | + inputs: { |
| 61 | + "release-type": "minor" |
| 62 | + } |
| 63 | + }); |
0 commit comments