Repository navigation
65 lines (60 loc) · 2.9 KB
/
Copy pathtemplate-sync.yaml
File metadata and controls
65 lines (60 loc) · 2.9 KB
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
name: 🔄 Template Sync
on:
schedule:
- cron: "0 6 * * 1" # weekly, Monday 06:00 UTC
workflow_dispatch:
permissions: {}
jobs:
# Names the missing App configuration instead of letting the sync fail inside the
# token step with no hint at what to set (docs/BOOTSTRAP.md, section 2).
app-config:
name: 🔑 Check template sync App configuration
if: github.repository != 'devantler-tech/platform-template'
runs-on: ubuntu-latest
permissions: {}
steps:
- name: 🛡️ Harden runner
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
with:
egress-policy: audit
- name: 🔑 Require the App client ID and private key
env:
APP_CLIENT_ID: ${{ vars.APP_CLIENT_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
run: |
missing=()
[[ -n "${APP_CLIENT_ID}" ]] || missing+=("the APP_CLIENT_ID variable")
[[ -n "${APP_PRIVATE_KEY}" ]] || missing+=("the APP_PRIVATE_KEY secret")
if ((${#missing[@]} > 0)); then
joined="${missing[0]}"
((${#missing[@]} == 1)) || joined="${missing[0]} and ${missing[1]}"
echo "::error title=Template sync is not configured::Set ${joined} for this repository's GitHub App; see docs/BOOTSTRAP.md, section 2 (Let the same App run the weekly template sync)."
exit 1
fi
template-sync:
needs: app-config
# Skipped in the template repo itself (it is the sync source); runs in every
# instance created from this template, where it opens a PR with template changes.
if: github.repository != 'devantler-tech/platform-template'
# The reusable workflow's job opens the sync PR, so the caller must grant it
# write to contents + pull-requests. A reusable workflow cannot be granted
# more than the caller, and the top-level `permissions: {}` grants none, so
# without this the run fails at startup (reusable-workflow permission check)
# — both here and in every instance where the job actually runs.
# id-token: write lets the shared workflow prove its identity to the GitHub
# token broker (devantler-tech/monorepo ADR 0020) instead of minting from the
# App key. Granting it is harmless until the workflow asks for it, and it must
# be here first: a reusable job that asks for more than its caller grants
# fails at startup.
permissions:
contents: write
pull-requests: write
id-token: write
uses: devantler-tech/.github/.github/workflows/template-sync.yaml@f6b200f553bdd94e269c3ee60a93a09c2ad415e4 # v22.5.0
with:
source-repo-path: devantler-tech/platform-template
# Push with the App token: GITHUB_TOKEN can never update workflow files, so a
# template change under .github/workflows would otherwise stop the sync.
use-app-token: true
secrets:
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}