fix(ci): gate secret steps on env, not the secrets context (invalid in if:)
This commit is contained in:
1 parent
a50bb6e8e3
commit
cbe73b9aa4
2 files changed
+21
-17
No files matched your search
@@ -304,6 +304,14 @@ jobs:
|
|||||||
packaging:
|
packaging:
|
||||||
needs: checksums
|
needs: checksums
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
# The two release credentials live in job-level env because GitHub does not
|
||||||
|
# expose the `secrets` context inside `if:` expressions (a step-level
|
||||||
|
# `if: secrets.X != ''` fails workflow parsing with "Unrecognized
|
||||||
|
# named-value: 'secrets'"). `env` *is* available in a step-level `if`, so
|
||||||
|
# the guards below test the mapped env vars instead.
|
||||||
|
env:
|
||||||
|
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
||||||
|
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -329,9 +337,7 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Update Homebrew tap formula
|
- name: Update Homebrew tap formula
|
||||||
if: secrets.HOMEBREW_TAP_TOKEN != ''
|
if: env.HOMEBREW_TAP_TOKEN != ''
|
||||||
env:
|
|
||||||
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
version="${GITHUB_REF_NAME#v}"
|
version="${GITHUB_REF_NAME#v}"
|
||||||
echo "HOMEBREW_TAP_TOKEN is present; pushing formula to zgs225/homebrew-tap..."
|
echo "HOMEBREW_TAP_TOKEN is present; pushing formula to zgs225/homebrew-tap..."
|
||||||
@@ -351,9 +357,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Update Arch Linux AUR package
|
- name: Update Arch Linux AUR package
|
||||||
if: secrets.AUR_SSH_KEY != ''
|
if: env.AUR_SSH_KEY != ''
|
||||||
env:
|
|
||||||
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
|
|
||||||
run: |
|
run: |
|
||||||
version="${GITHUB_REF_NAME#v}"
|
version="${GITHUB_REF_NAME#v}"
|
||||||
echo "AUR_SSH_KEY is present; pushing to aur@aur.archlinux.org/pi2d-bin.git..."
|
echo "AUR_SSH_KEY is present; pushing to aur@aur.archlinux.org/pi2d-bin.git..."
|
||||||
|
|||||||
@@ -26,15 +26,17 @@ jobs:
|
|||||||
tap:
|
tap:
|
||||||
name: homebrew tap token
|
name: homebrew tap token
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
# `secrets` is not a valid context inside `if:` (the parser rejects the whole
|
||||||
|
# workflow); map it to env at job level and test the env var instead.
|
||||||
|
env:
|
||||||
|
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: not configured
|
- name: not configured
|
||||||
if: secrets.HOMEBREW_TAP_TOKEN == ''
|
if: env.HOMEBREW_TAP_TOKEN == ''
|
||||||
run: echo "::warning::HOMEBREW_TAP_TOKEN is not set — the packaging job will only print manual instructions"
|
run: echo "::warning::HOMEBREW_TAP_TOKEN is not set — the packaging job will only print manual instructions"
|
||||||
|
|
||||||
- name: read access
|
- name: read access
|
||||||
if: secrets.HOMEBREW_TAP_TOKEN != ''
|
if: env.HOMEBREW_TAP_TOKEN != ''
|
||||||
env:
|
|
||||||
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
remote="https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/zgs225/homebrew-tap.git"
|
remote="https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/zgs225/homebrew-tap.git"
|
||||||
if ! git ls-remote "$remote" HEAD >/dev/null 2>&1; then
|
if ! git ls-remote "$remote" HEAD >/dev/null 2>&1; then
|
||||||
@@ -44,9 +46,7 @@ jobs:
|
|||||||
echo "read ok: token can see zgs225/homebrew-tap"
|
echo "read ok: token can see zgs225/homebrew-tap"
|
||||||
|
|
||||||
- name: write access (throwaway branch)
|
- name: write access (throwaway branch)
|
||||||
if: secrets.HOMEBREW_TAP_TOKEN != ''
|
if: env.HOMEBREW_TAP_TOKEN != ''
|
||||||
env:
|
|
||||||
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
branch="verify-secrets-${GITHUB_RUN_ID}"
|
branch="verify-secrets-${GITHUB_RUN_ID}"
|
||||||
remote="https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/zgs225/homebrew-tap.git"
|
remote="https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/zgs225/homebrew-tap.git"
|
||||||
@@ -69,15 +69,15 @@ jobs:
|
|||||||
aur:
|
aur:
|
||||||
name: aur ssh key
|
name: aur ssh key
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
|
||||||
steps:
|
steps:
|
||||||
- name: not configured
|
- name: not configured
|
||||||
if: secrets.AUR_SSH_KEY == ''
|
if: env.AUR_SSH_KEY == ''
|
||||||
run: echo "::warning::AUR_SSH_KEY is not set — the packaging job will only print manual instructions for pi2d-bin"
|
run: echo "::warning::AUR_SSH_KEY is not set — the packaging job will only print manual instructions for pi2d-bin"
|
||||||
|
|
||||||
- name: key authenticates
|
- name: key authenticates
|
||||||
if: secrets.AUR_SSH_KEY != ''
|
if: env.AUR_SSH_KEY != ''
|
||||||
env:
|
|
||||||
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
printf '%s\n' "$AUR_SSH_KEY" > ~/.ssh/aur_ed25519
|
printf '%s\n' "$AUR_SSH_KEY" > ~/.ssh/aur_ed25519
|
||||||
|
|||||||
Reference in new issue
Block a user