-
Notifications
You must be signed in to change notification settings - Fork 114
69 lines (56 loc) · 1.79 KB
/
publish-npm-packages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: publish npm packages
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
on:
workflow_dispatch:
# trigger this workflow when the CI workflow is completed
workflow_run:
workflows: ["Continuous Integration"]
branches: [main]
types:
- completed
jobs:
publish:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js 22
uses: actions/setup-node@v3
with:
node-version: 22
cache: "pnpm"
# Check if any package needs to be published
- name: Check if publish is needed
id: check_publish
run: |
echo "Running pnpm publish --dry-run"
pnpm publish --dry-run > publish_output.txt 2>&1 || true
if grep -q "published" publish_output.txt; then
echo "needs_publish=true" >> $GITHUB_ENV
else
echo "No packages need to be published"
echo "needs_publish=false" >> $GITHUB_ENV
fi
# Conditional steps based on the check
- name: Install Dependencies
if: env.needs_publish == 'true'
run: pnpm install
- name: Install Doppler CLI for env variables
if: env.needs_publish == 'true'
uses: dopplerhq/cli-action@v2
- name: Build
if: env.needs_publish == 'true'
run: doppler run -- pnpm build
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_PRODUCTION_ENV_TOKEN }}
- name: Publish packages
if: env.needs_publish == 'true'
run: pnpm ci:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}