summaryrefslogtreecommitdiff
path: root/.github/workflows/beta-continue.yml
blob: 5c1f2347f3f3868c2b285e74cb453d96747a18d3 (plain)
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: Scheduled Beta Continue

on:
  workflow_run:
    workflows: ["CI", "Prepare Release Candidate", "Prepare Release Dependencies", "Promote Release Source"]
    types: [completed]
    branches: ["release/**", "develop"]

permissions: {}

jobs:
  gate:
    if: >-
      github.event.workflow_run.actor.type == 'Bot' &&
      (github.event.workflow_run.head_branch != 'develop' ||
       github.event.workflow_run.path == '.github/workflows/prepare-release-dependencies.yml')
    runs-on: ubuntu-latest
    timeout-minutes: 5
    outputs:
      enabled: ${{ steps.gate.outputs.enabled }}
    steps:
      - name: Require BETA_AUTOMATION=enabled
        id: gate
        env:
          BETA_AUTOMATION: ${{ vars.BETA_AUTOMATION }}
          RUN_URL: ${{ github.event.workflow_run.html_url }}
        run: |
          if [ "$BETA_AUTOMATION" = enabled ]; then
            echo "enabled=true" >> "$GITHUB_OUTPUT"
          else
            echo "Scheduled betas are paused: BETA_AUTOMATION is '${BETA_AUTOMATION:-<unset>}', not 'enabled'. Nothing was done after $RUN_URL." >> "$GITHUB_STEP_SUMMARY"
          fi

  continuation:
    needs: gate
    if: needs.gate.outputs.enabled == 'true'
    runs-on: ubuntu-latest
    timeout-minutes: 10
    environment: beta-automation
    # Shared with the cut, so only one scheduler step acts at a time.
    concurrency:
      group: beta-scheduler
      cancel-in-progress: false
    permissions:
      contents: read
      issues: write
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          persist-credentials: false
      - name: Mint the release-bot token
        id: app-token
        uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
        with:
          # The token's JWT issuer may be the App ID or the client ID.
          client-id: ${{ vars.RELEASE_BOT_APP_ID }}
          private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
          permission-actions: write
          permission-contents: read
      - name: Continue the beta
        id: scheduler
        env:
          RELEASE_BOT_TOKEN: ${{ steps.app-token.outputs.token }}
          RELEASE_BOT_SLUG: ${{ steps.app-token.outputs.app-slug }}
          GITHUB_TOKEN: ${{ github.token }}
        run: python3 .github/scripts/beta-scheduler.py continue
      - name: Record an unreported failure
        if: failure() && steps.scheduler.outputs.alerted != 'true'
        env:
          GITHUB_TOKEN: ${{ github.token }}
        run: python3 .github/scripts/beta-scheduler.py alert --stage continue --reason "The beta-continue job failed before the scheduler reported a result."