Skip to content

Commit 4ab400f

Browse files
committed
fix: use env var to check NPM_TOKEN in workflow
secrets context is not available in job-level if conditions. Pass secret as env var and check in step, then use output for conditional publish.
1 parent 7c4d8b9 commit 4ab400f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
publish-npm:
3030
needs: build-and-test
3131
runs-on: ubuntu-latest
32-
if: ${{ secrets.NPM_TOKEN != '' }}
3332
steps:
3433
- uses: actions/checkout@v4
3534

@@ -46,7 +45,20 @@ jobs:
4645
- name: Build Web UI
4746
run: npm run build:web-ui
4847

48+
- name: Check NPM_TOKEN
49+
id: check_token
50+
env:
51+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
run: |
53+
if [ -z "$NPM_TOKEN" ]; then
54+
echo "has_token=false" >> $GITHUB_OUTPUT
55+
echo "::warning::NPM_TOKEN not configured, skipping npm publish"
56+
else
57+
echo "has_token=true" >> $GITHUB_OUTPUT
58+
fi
59+
4960
- name: Publish to npm
61+
if: steps.check_token.outputs.has_token == 'true'
5062
run: npm publish --access public
5163
env:
5264
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)