Skip to content

Commit be6c59c

Browse files
committed
refactor: use workflow_run instead of workflow_call
- publish.yml now triggers automatically after ci.yml completes - Removed publish job from ci.yml (no longer needed) - Only publishes if CI workflow succeeded - Cleaner pattern: workflows are decoupled and run independently - publish.yml triggers on both tag pushes and ci completion
1 parent a9e2bb4 commit be6c59c

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,3 @@ jobs:
113113

114114
- name: Build library
115115
run: bun run build
116-
117-
# Call publish workflow after all checks pass on main
118-
publish:
119-
name: publish to npm
120-
# Only publish on main branch pushes after all checks pass
121-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
122-
needs: [fmt, lint, typecheck, test, build]
123-
uses: ./.github/workflows/publish.yml
124-
permissions:
125-
contents: read
126-
id-token: write # Required for OIDC trusted publishing

.github/workflows/publish.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ on:
44
push:
55
tags:
66
- 'v*'
7-
workflow_call:
8-
# Allow calling from other workflows (e.g., ci.yml)
7+
workflow_run:
8+
workflows: ["ci"]
9+
types:
10+
- completed
11+
branches:
12+
- main
913

1014
permissions:
1115
contents: read
@@ -15,6 +19,8 @@ jobs:
1519
publish:
1620
name: publish to npm
1721
runs-on: ubuntu-latest
22+
# Only run if CI workflow succeeded (for workflow_run trigger)
23+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' }}
1824
steps:
1925
- name: Checkout code
2026
uses: actions/checkout@v4

0 commit comments

Comments
 (0)