Skip to content

Commit 44c9ac0

Browse files
committed
fix: guard catalog refresh workflow
Move the secret into job env. Stop referencing secrets directly in step if conditions. Add CI checks for workflow guard regressions.
1 parent 4caf036 commit 44c9ac0

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: rhysd/actionlint@v1.7.11
1515
- name: Validate script syntax
16-
run: bash -n scripts/check-apps-manifest.sh scripts/check-app-builds.sh
16+
run: bash -n scripts/check-apps-manifest.sh scripts/check-app-builds.sh scripts/check-workflow-guards.sh
17+
- name: Validate workflow guards
18+
run: bash scripts/check-workflow-guards.sh
1719
- name: Validate manifest and source layout
1820
run: bash scripts/check-apps-manifest.sh
1921
- name: Build application images

.github/workflows/publish-images.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ jobs:
101101
refresh-catalogs:
102102
needs: publish
103103
runs-on: ubuntu-latest
104+
env:
105+
CATALOG_REFRESH_TOKEN: ${{ secrets.CATALOG_REFRESH_TOKEN }}
104106
steps:
105107
- name: Trigger downstream catalog refresh
106-
if: ${{ secrets.CATALOG_REFRESH_TOKEN != '' }}
107-
env:
108-
CATALOG_REFRESH_TOKEN: ${{ secrets.CATALOG_REFRESH_TOKEN }}
108+
if: ${{ env.CATALOG_REFRESH_TOKEN != '' }}
109109
run: |
110110
set -euo pipefail
111111
for repo in sw-ourbox-catalog-demo; do

scripts/check-workflow-guards.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
6+
matches="$(grep -RInE '^[[:space:]]*if:.*\bsecrets\.' "${ROOT}/.github/workflows" || true)"
7+
if [[ -n "${matches}" ]]; then
8+
echo "workflow if conditions must not reference secrets.* directly" >&2
9+
echo "${matches}" >&2
10+
exit 1
11+
fi
12+
13+
echo "Workflow guard checks passed."

0 commit comments

Comments
 (0)