Skip to content

Commit 9372983

Browse files
wochingeclaude
andauthored
ci: harden GitHub Actions workflows with zizmor (#783)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c17be33 commit 9372983

6 files changed

Lines changed: 76 additions & 18 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- main
88
workflow_dispatch:
99

10+
permissions: {}
11+
1012
concurrency:
1113
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1214
cancel-in-progress: true
@@ -22,6 +24,8 @@ jobs:
2224
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
2325
steps:
2426
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
27+
with:
28+
persist-credentials: false
2529
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
2630
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2731
with:
@@ -49,6 +53,8 @@ jobs:
4953

5054
steps:
5155
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
56+
with:
57+
persist-credentials: false
5258
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
5359
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
5460
with:
@@ -144,6 +150,8 @@ jobs:
144150
runs-on: blacksmith-2vcpu-ubuntu-2404
145151
steps:
146152
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
153+
with:
154+
persist-credentials: false
147155
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
148156
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
149157
with:

.github/workflows/claude-review-maintainer-prs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
name: Claude Review on Maintainer PRs
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
types:
66
- opened
77
- ready_for_review
88

99
jobs:
1010
comment:
11-
if: github.event.pull_request.draft == false
11+
# Only run on PRs that are not drafts and are from the same repository (i.e., not from forks)
12+
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository
1213
runs-on: ubuntu-latest
1314
permissions:
1415
issues: write

.github/workflows/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
steps:
4848
- name: Checkout repository
4949
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
50+
with:
51+
persist-credentials: false
5052

5153
# Initializes the CodeQL tools for scanning.
5254
- name: Initialize CodeQL

.github/workflows/dependabot-rebase-stale.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
- main
77
workflow_dispatch:
88

9+
permissions: {}
10+
911
jobs:
1012
rebase-dependabot:
1113
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,26 @@ jobs:
4848
steps:
4949
- name: Verify branch
5050
run: |
51-
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
51+
if [ "${GITHUB_REF}" != "refs/heads/main" ]; then
5252
echo "❌ Error: Releases can only be triggered from main branch"
53-
echo "Current ref: ${{ github.ref }}"
53+
echo "Current ref: ${GITHUB_REF}"
5454
exit 1
5555
fi
5656
- name: Confirm major release
5757
if: ${{ inputs.version == 'major' || inputs.version == 'premajor' }}
5858
run: |
59-
if [ "${{ inputs.confirm_major }}" != "RELEASE MAJOR" ]; then
59+
if [ "${INPUTS_CONFIRM_MAJOR}" != "RELEASE MAJOR" ]; then
6060
echo "❌ For major/premajor releases, set confirm_major to RELEASE MAJOR"
6161
exit 1
6262
fi
63+
env:
64+
INPUTS_CONFIRM_MAJOR: ${{ inputs.confirm_major }}
6365
- name: Checkout repository
6466
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
6567
with:
6668
fetch-depth: 0
6769
token: ${{ secrets.GH_ACCESS_TOKEN }}
70+
persist-credentials: false
6871

6972
- name: Setup pnpm
7073
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
@@ -74,6 +77,7 @@ jobs:
7477
with:
7578
node-version: 24
7679
registry-url: "https://registry.npmjs.org"
80+
cache: "" # Disable cache for release workflow (publishes to npm)
7781

7882
- name: Configure Git
7983
env:
@@ -98,11 +102,14 @@ jobs:
98102
99103
- name: Determine release parameters
100104
id: release-params
105+
env:
106+
INPUTS_VERSION: ${{ inputs.version }}
107+
INPUTS_PRERELEASE_TYPE: ${{ inputs.prerelease_type }}
101108
run: |
102-
version_type="${{ inputs.version }}"
109+
version_type="${INPUTS_VERSION}"
103110
104111
if [ "$version_type" = "prepatch" ] || [ "$version_type" = "preminor" ] || [ "$version_type" = "premajor" ]; then
105-
prerelease_type="${{ inputs.prerelease_type }}"
112+
prerelease_type="${INPUTS_PRERELEASE_TYPE}"
106113
if [ -z "$prerelease_type" ]; then
107114
echo "❌ Error: prerelease_type must be specified when version is prepatch/preminor/premajor"
108115
exit 1
@@ -200,17 +207,21 @@ jobs:
200207
env:
201208
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
202209
NPM_CONFIG_TAG: ${{ steps.release-params.outputs.tag }}
210+
STEPS_RELEASE_PARAMS_OUTPUTS_RELEASE_INCREMENT: ${{ steps.release-params.outputs.release_increment }}
211+
STEPS_RELEASE_PARAMS_OUTPUTS_PRE_RELEASE_FLAG: ${{ steps.release-params.outputs.pre_release_flag }}
203212
run: |
204-
pnpm exec release-it ${{ steps.release-params.outputs.release_increment }} ${{ steps.release-params.outputs.pre_release_flag }} --ci --config .release-it.ci.json
213+
pnpm exec release-it ${STEPS_RELEASE_PARAMS_OUTPUTS_RELEASE_INCREMENT} ${STEPS_RELEASE_PARAMS_OUTPUTS_PRE_RELEASE_FLAG} --ci --config .release-it.ci.json
205214
206215
- name: Run release-it (dry run)
207216
if: inputs.dry_run == true
208217
env:
209218
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
210219
NPM_CONFIG_TAG: ${{ steps.release-params.outputs.tag }}
220+
STEPS_RELEASE_PARAMS_OUTPUTS_RELEASE_INCREMENT: ${{ steps.release-params.outputs.release_increment }}
221+
STEPS_RELEASE_PARAMS_OUTPUTS_PRE_RELEASE_FLAG: ${{ steps.release-params.outputs.pre_release_flag }}
211222
run: |
212223
echo "🧪 Running in DRY RUN mode - no changes will be pushed"
213-
pnpm exec release-it ${{ steps.release-params.outputs.release_increment }} ${{ steps.release-params.outputs.pre_release_flag }} --ci --config .release-it.ci.json --dry-run
224+
pnpm exec release-it ${STEPS_RELEASE_PARAMS_OUTPUTS_RELEASE_INCREMENT} ${STEPS_RELEASE_PARAMS_OUTPUTS_PRE_RELEASE_FLAG} --ci --config .release-it.ci.json --dry-run
214225
215226
- name: Get version
216227
id: version
@@ -223,20 +234,20 @@ jobs:
223234
for pkg in packages/*/dist; do
224235
pkg_name=$(basename $(dirname $pkg))
225236
echo "Creating archive for $pkg_name..."
226-
tar -czf release-artifacts/langfuse-js-sdk-${pkg_name}-${{ steps.version.outputs.version }}.tar.gz -C $(dirname $pkg) dist
237+
tar -czf release-artifacts/langfuse-js-sdk-${pkg_name}-${STEPS_VERSION_OUTPUTS_VERSION}.tar.gz -C $(dirname $pkg) dist
227238
done
228239
echo "Build artifacts:"
229240
ls -lh release-artifacts/
241+
env:
242+
STEPS_VERSION_OUTPUTS_VERSION: ${{ steps.version.outputs.version }}
230243

231244
- name: Upload release artifacts to GitHub Release
232245
if: inputs.dry_run == false
233-
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
234-
with:
235-
tag_name: v${{ steps.version.outputs.version }}
236-
files: release-artifacts/*.tar.gz
237-
fail_on_unmatched_files: true
246+
run: |
247+
gh release upload "v${VERSION}" release-artifacts/*.tar.gz --clobber
238248
env:
239-
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
249+
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
250+
VERSION: ${{ steps.version.outputs.version }}
240251

241252
- name: Notify Slack on success
242253
if: success() && inputs.dry_run == false
@@ -510,9 +521,11 @@ jobs:
510521
if: failure() && steps.release.outcome == 'success'
511522
run: |
512523
echo "⚠️ CRITICAL: Release succeeded but subsequent steps failed"
513-
echo "Published version: v${{ steps.version.outputs.version }}"
524+
echo "Published version: v${STEPS_VERSION_OUTPUTS_VERSION}"
514525
echo "Manual intervention may be required"
515526
echo ""
516527
echo "Options:"
517528
echo "1. Re-run the workflow to complete GitHub release artifacts upload"
518-
echo "2. Manually upload release artifacts for tag v${{ steps.version.outputs.version }}"
529+
echo "2. Manually upload release artifacts for tag v${STEPS_VERSION_OUTPUTS_VERSION}"
530+
env:
531+
STEPS_VERSION_OUTPUTS_VERSION: ${{ steps.version.outputs.version }}

.github/workflows/zizmor.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Check GitHub Actions
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- "main"
9+
merge_group:
10+
pull_request:
11+
branches:
12+
- "main"
13+
14+
permissions: {}
15+
16+
jobs:
17+
zizmor:
18+
name: Check GitHub Actions security
19+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
20+
runs-on: ubuntu-latest
21+
permissions:
22+
security-events: write
23+
contents: read
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
27+
with:
28+
persist-credentials: false
29+
- name: Run zizmor
30+
uses: zizmorcore/zizmor-action@b1d7e1fb5de872772f31590499237e7cce841e8e # v0.5.3
31+
with:
32+
advanced-security: true

0 commit comments

Comments
 (0)