|
| 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 }} |
0 commit comments