summaryrefslogtreecommitdiff
path: root/.github/workflows/build-announcements.yml
blob: 426b6214ceac7e1e95f8cda0aa0fbc03ec9e75d8 (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
72
73
74
75
76
name: Build announcements.json

on:
  schedule:
    - cron: '17 * * * *'
  repository_dispatch:
    types: [build-announcements]
  workflow_dispatch:
    inputs:
      branch:
        description: Target branch
        required: true
        type: choice
        options:
          - stable
          - testing
          - unstable

permissions:
  contents: write

jobs:
  select:
    runs-on: ubuntu-latest
    outputs:
      branches: ${{ steps.target.outputs.branches }}
    steps:
      - name: Resolve target branches
        id: target
        env:
          DISPATCH_BRANCH: ${{ github.event.client_payload.branch }}
          INPUT_BRANCH: ${{ github.event.inputs.branch }}
        run: |
          if [ "$GITHUB_EVENT_NAME" = schedule ]; then
            echo 'branches=["stable","testing"]' >> "$GITHUB_OUTPUT"
            exit 0
          fi
          BRANCH="${DISPATCH_BRANCH:-${INPUT_BRANCH:-stable}}"
          case "$BRANCH" in
            stable|testing|unstable) ;;
            *) echo "::error::invalid or missing branch: '$BRANCH'"; exit 1 ;;
          esac
          echo "branches=[\"$BRANCH\"]" >> "$GITHUB_OUTPUT"

  build:
    needs: select
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        branch: ${{ fromJSON(needs.select.outputs.branches) }}
    concurrency:
      group: build-announcements-${{ matrix.branch }}
      cancel-in-progress: false
    steps:

      - uses: actions/checkout@v4
        with:
          ref: ${{ matrix.branch }}

      - name: Build announcements.json
        run: python3 .github/scripts/build-announcements.py
        env:
          RELEASE_BRANCH: ${{ matrix.branch }}
          SOURCE_REPO: AeroCore-IO/AeroCore-OS
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TZ: UTC

      - name: Commit if changed
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add announcements.json docs/
          git diff --cached --quiet || git commit -m "chore: rebuild game mode announcements" -m "Refresh Steam update notes from AeroCore OS releases."
          git pull --rebase
          git push