|
| 1 | +# This file is managed by nsheaps/.github (sync-files). |
| 2 | +# Source: https://github.com/nsheaps/.github/blob/main/ansible/templates/.github/workflows/apply-repo-settings.yaml |
| 3 | +# Edit-in-place will be overwritten on the next sync. |
| 4 | +name: Apply Repo Settings |
| 5 | + |
| 6 | +# Reads `.github/settings.yml` from THIS repo and applies the |
| 7 | +# repository config + rulesets via the apply-repo-settings action |
| 8 | +# (https://github.com/nsheaps/github-actions/tree/main/.github/actions/apply-repo-settings). |
| 9 | +# |
| 10 | +# Ephemeral, in-workflow alternative to the third-party |
| 11 | +# repository-settings GitHub App. Runs only when invoked. |
| 12 | +# |
| 13 | +# Auth: reuses the org's automation App (AUTOMATION_GITHUB_APP_*) — |
| 14 | +# same app used by sync-labels / sync-files / sync-secrets / sync-stars. |
| 15 | +# That app must have `Administration: write` for rulesets to apply; if |
| 16 | +# they don't, check the app's permission grants first. |
| 17 | +# |
| 18 | +# Triggers: |
| 19 | +# workflow_dispatch manual, with dry-run toggle |
| 20 | +# repository_dispatch external triggers (other workflows / curl) |
| 21 | +# push to main when .github/settings.yml changes |
| 22 | + |
| 23 | +# checkov:skip=CKV_GHA_7:dry-run is a boolean preview/apply toggle for a |
| 24 | +# repo-settings sync, not a build parameter -- this workflow produces no |
| 25 | +# build artifact for the SLSA parameterless-triggers rule to protect. |
| 26 | +on: |
| 27 | + workflow_dispatch: |
| 28 | + inputs: |
| 29 | + dry-run: |
| 30 | + description: "Render only; don't apply" |
| 31 | + type: boolean |
| 32 | + default: false |
| 33 | + repository_dispatch: |
| 34 | + types: [apply-repo-settings] |
| 35 | + push: |
| 36 | + branches: [main] |
| 37 | + paths: |
| 38 | + - '.github/settings.yml' |
| 39 | + - '.github/workflows/apply-repo-settings.yaml' |
| 40 | + |
| 41 | +permissions: |
| 42 | + contents: read |
| 43 | + |
| 44 | +concurrency: |
| 45 | + # Serialize per-ref so a fast follow-up push waits for the in-flight run. |
| 46 | + group: apply-repo-settings-${{ github.ref }} |
| 47 | + cancel-in-progress: false |
| 48 | + |
| 49 | +jobs: |
| 50 | + apply: |
| 51 | + name: Apply settings to this repo |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - name: Checkout as GitHub App |
| 55 | + id: checkout |
| 56 | + uses: nsheaps/github-actions/.github/actions/checkout-as-app@1e129396b6f0b39257efac9a255010fe64a68ef8 # main |
| 57 | + with: |
| 58 | + app-id: ${{ secrets.AUTOMATION_GITHUB_APP_ID }} |
| 59 | + private-key: ${{ secrets.AUTOMATION_GITHUB_APP_PRIVATE_KEY }} |
| 60 | + |
| 61 | + - name: Apply |
| 62 | + id: apply |
| 63 | + uses: nsheaps/github-actions/.github/actions/apply-repo-settings@1e129396b6f0b39257efac9a255010fe64a68ef8 # main |
| 64 | + with: |
| 65 | + token: ${{ steps.checkout.outputs.token }} |
| 66 | + dry-run: ${{ inputs.dry-run || false }} |
| 67 | + |
| 68 | + - name: Show summary |
| 69 | + if: always() |
| 70 | + run: | |
| 71 | + echo "Summary: ${{ steps.apply.outputs.summary }}" |
0 commit comments