Skip to content

Commit f96f1df

Browse files
authored
Merge pull request #74 from dafyddj/feat/add-safe-settings
feat(safe-settings): initial commit of GitHub's `safe-settings` utility
2 parents 53c2a90 + 51e90ee commit f96f1df

5 files changed

Lines changed: 84 additions & 1 deletion

File tree

.github/workflows/commitlint.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
name: Commitlint
55
'on': [pull_request]
66

7+
permissions: {}
8+
79
jobs:
810
lint:
11+
permissions:
12+
contents: read
913
runs-on: ubuntu-latest
1014
env:
1115
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1216
steps:
1317
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1418
with:
1519
fetch-depth: 0
20+
persist-credentials: false
1621
- uses: wagoid/commitlint-github-action@a85daedc64529d02d566e7f83c3c48c77e78af85 # v1

.github/workflows/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
1111

12+
permissions: {}
13+
1214
jobs:
1315
should-run:
1416
name: Prep / Should run
@@ -24,10 +26,14 @@ jobs:
2426
needs: should-run
2527
if: fromJSON(needs.should-run.outputs.should-run)
2628
container: techneg/ci-pre-commit:v2.5.26@sha256:46f3dbce03b7446d3f5ed4f45303eb0035dfd1d090e89d7a83e2e55f172bbd17
29+
permissions:
30+
contents: read
2731
runs-on: ubuntu-latest
2832
timeout-minutes: 5
2933
steps:
3034
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
35+
with:
36+
persist-credentials: false
3137
- name: Export `CI_CACHE_ID` from container
3238
run: echo "CI_CACHE_ID=$(cat /.ci_cache_id)" >> $GITHUB_ENV
3339
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Apply Safe Settings
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
dry-run:
6+
description: Whether to run in `dry-run` mode or not
7+
required: false
8+
type: boolean
9+
default: true
10+
11+
permissions: {}
12+
13+
jobs:
14+
apply-safe-settings:
15+
permissions:
16+
contents: read
17+
runs-on: ubuntu-24.04
18+
env:
19+
# Version/tag of `github/safe-settings` repository to use:
20+
SAFE_SETTINGS_VERSION: 2.1.18
21+
22+
# Path on GHA runner box where safe-settings code downloaded to:
23+
SAFE_SETTINGS_CODE_DIR: ${{ github.workspace }}/.safe-settings-code
24+
steps:
25+
# Self-checkout of 'admin' repo for access to safe-settings deployment configuration
26+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
27+
with:
28+
persist-credentials: false
29+
30+
# Checkout of `safe-settings` source repository to apply all settings
31+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
32+
with:
33+
repository: github/safe-settings
34+
ref: ${{ env.SAFE_SETTINGS_VERSION }}
35+
path: ${{ env.SAFE_SETTINGS_CODE_DIR }}
36+
persist-credentials: false
37+
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
38+
- run: npm install
39+
working-directory: ${{ env.SAFE_SETTINGS_CODE_DIR }}
40+
- name: Run Safe-Settings Full-Sync
41+
run: |
42+
set +e # Allow commands to fail
43+
npm run full-sync
44+
exit_code=$?
45+
echo "Full-sync exit code: $exit_code"
46+
47+
if [[ "$FULL_SYNC_NOP" == "true" ]]; then
48+
echo "Dry-run mode — ignoring failure"
49+
exit 0
50+
fi
51+
52+
exit $exit_code
53+
working-directory: ${{ env.SAFE_SETTINGS_CODE_DIR }}
54+
env:
55+
APP_ID: ${{ vars.SAFE_SETTINGS_APP_ID }}
56+
ADMIN_REPO: ${{ vars.SAFE_SETTINGS_ADMIN_REPO || '.github' }}
57+
CONFIG_PATH: ${{ vars.SAFE_SETTINGS_CONFIG_PATH || 'safe-settings' }}
58+
DEPLOYMENT_CONFIG_FILE: ${{ github.workspace }}/${{ vars.SAFE_SETTINGS_CONFIG_PATH || 'safe-settings' }}/deployment-settings.yml
59+
FULL_SYNC_NOP: ${{ inputs.dry-run }}
60+
GH_ORG: ${{ vars.SAFE_SETTINGS_GH_ORG }}
61+
LOG_LEVEL: ${{ vars.SAFE_SETTINGS_LOG_LEVEL || 'debug' }}
62+
PRIVATE_KEY: ${{ secrets.SAFE_SETTINGS_PRIVATE_KEY }}

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ repos:
1414
rev: 0.36.0
1515
hooks:
1616
- id: check-github-workflows
17-
name: Check GitHub workflows with check-jsonschema
17+
name: Check GitHub Actions workflows with check-jsonschema
1818
args: ["--verbose"]
19+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
20+
rev: v1.22.0
21+
hooks:
22+
- id: zizmor
23+
name: Check GitHub Actions workflows with zizmor
1924
- repo: https://github.com/renovatebot/pre-commit-hooks
2025
rev: 42.84.0
2126
hooks:

safe-settings/settings.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repository:
2+
topics:
3+
- template
4+
- salt-formula
5+
- saltstack-formula

0 commit comments

Comments
 (0)