summaryrefslogtreecommitdiff
path: root/.github/workflows/beta-cut.yml
blob: 657c0ea8a765f5425647ac1a5ccb099f0fbcba51 (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
name: Scheduled Beta Cut

on:
  schedule:
    - cron: "0 20 * * 2"
  workflow_dispatch:

permissions: {}

jobs:
  gate:
    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: |
          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." >> "$GITHUB_STEP_SUMMARY"
          fi

  cut:
    needs: gate
    if: needs.gate.outputs.enabled == 'true'
    runs-on: ubuntu-latest
    timeout-minutes: 30
    environment: beta-automation
    # Shared with the continuation, so only one scheduler step acts at a time.
    concurrency:
      group: beta-scheduler
      cancel-in-progress: false
    permissions:
      contents: read
      issues: write
      packages: read
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          fetch-depth: 0
          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: write
          permission-workflows: write
      - name: Advance the beta line
        id: scheduler
        env:
          RELEASE_BOT_TOKEN: ${{ steps.app-token.outputs.token }}
          RELEASE_BOT_SLUG: ${{ steps.app-token.outputs.app-slug }}
          GITHUB_TOKEN: ${{ github.token }}
          PUBLIC_READ_TOKEN: ${{ github.token }}
        run: python3 .github/scripts/beta-scheduler.py cut
      - 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 cut --reason "The beta-cut job failed before the scheduler reported a result."