Skip to content

Commit 5184d19

Browse files
committed
chore: refactor
1 parent a20d487 commit 5184d19

4 files changed

Lines changed: 146 additions & 56 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'Publish Beta Steps'
2+
description: 'Steps to run when packages are not published (beta branch)'
3+
inputs:
4+
branch:
5+
description: 'Branch/ref for PR creation'
6+
required: false
7+
default: 'main'
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Create PR for beta publish
12+
shell: bash
13+
run: pnpm pkg-pr-new publish './packages/*' './packages/sdk-effects/*' --packageManager=pnpm --comment=off
14+
15+
- name: Publish api docs [beta]
16+
uses: JamesIves/github-pages-deploy-action@v4.7.3
17+
with:
18+
folder: docs
19+
commit-message: 'chore: release-api-docs-beta'
20+
target-folder: 'beta'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'Publish Release Steps'
2+
description: 'Steps to run when packages are published'
3+
inputs:
4+
publishedPackages:
5+
description: 'Published packages JSON'
6+
required: true
7+
slackWebhook:
8+
description: 'Slack webhook URL'
9+
required: true
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Format publishedPackages for Slack
14+
id: slackify
15+
shell: bash
16+
run: |
17+
raw='${{ inputs.publishedPackages }}'
18+
message=$(echo "$raw" | jq -r '.[] | "- \(.name) v\(.version)"')
19+
echo "message=$message" >> $GITHUB_OUTPUT
20+
21+
- name: Send to Slack Workflow
22+
uses: slackapi/slack-github-action@v2.0.0
23+
with:
24+
webhook: ${{ inputs.slackWebhook }}
25+
webhook-type: webhook-trigger
26+
payload: >
27+
{
28+
"publishedPackages": "${{ steps.slackify.outputs.message }}"
29+
}
30+
31+
- name: Publish api docs
32+
uses: JamesIves/github-pages-deploy-action@v4.7.3
33+
with:
34+
folder: docs
35+
commit-message: 'chore: release-api-docs'

.github/actions/setup/action.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: 'Setup Project'
2+
description: 'Centralized setup for CI jobs'
3+
inputs:
4+
fetch-depth:
5+
description: 'Git fetch depth'
6+
required: false
7+
default: '0'
8+
token:
9+
description: 'GitHub token'
10+
required: true
11+
node-version-file:
12+
description: 'Node version file'
13+
required: false
14+
default: '.node-version'
15+
pnpm-cache-folder:
16+
description: 'pnpm cache folder'
17+
required: false
18+
default: '.pnpm-store'
19+
runs:
20+
using: 'composite'
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: ${{ inputs.fetch-depth }}
25+
token: ${{ inputs.token }}
26+
27+
- uses: pnpm/action-setup@v4
28+
with:
29+
run_install: false
30+
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version-file: ${{ inputs.node-version-file }}
34+
cache: 'pnpm'
35+
registry-url: 'https://registry.npmjs.org'
36+
37+
- name: Update npm
38+
run: npm install -g npm@latest
39+
shell: bash
40+
41+
- name: Install dependencies
42+
run: pnpm install --frozen-lockfile
43+
shell: bash
44+
45+
- name: Nx Cloud start
46+
run: pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
47+
shell: bash
48+
49+
- name: Cache Playwright browsers
50+
uses: actions/cache@v4
51+
with:
52+
path: ~/.cache/ms-playwright
53+
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
54+
restore-keys: |
55+
${{ runner.os }}-playwright-
56+
57+
- name: Install Playwright
58+
run: pnpm exec playwright install
59+
shell: bash
60+
61+
- uses: nrwl/nx-set-shas@v4
62+
63+
- name: Setup pnpm config
64+
run: pnpm config set store-dir ${{ inputs.pnpm-cache-folder }}
65+
shell: bash
66+
67+
- name: Run Nx build/lint/test/e2e
68+
run: pnpm exec nx affected -t build lint test e2e-ci
69+
shell: bash
70+
71+
- name: Upload Playwright report
72+
uses: actions/upload-artifact@v4
73+
if: ${{ !cancelled() }}
74+
with:
75+
name: playwright-report
76+
path: |
77+
./**/.playwright/**
78+
retention-days: 30

.github/workflows/publish.yml

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,17 @@ jobs:
4343
id-token: write # OIDC for provenance if npm publish happens here
4444
runs-on: ubuntu-latest
4545
steps:
46-
- uses: actions/checkout@v4
46+
- name: Setup Project
47+
uses: ./.github/actions/setup
4748
with:
4849
fetch-depth: 0
4950
token: ${{ secrets.GH_TOKEN }}
50-
- uses: pnpm/action-setup@v4
51-
with:
52-
run_install: false
51+
5352
- uses: actions/setup-node@v5
5453
id: cache
5554
with:
5655
node-version-file: '.node-version'
57-
cache: 'pnpm'
58-
registry-url: 'https://registry.npmjs.org'
59-
60-
- name: Update npm
61-
run: npm install -g npm@latest
62-
63-
- run: pnpm install --frozen-lockfile
64-
65-
- run: pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
66-
67-
- name: Cache Playwright browsers
68-
uses: actions/cache@v4
69-
with:
70-
path: ~/.cache/ms-playwright
71-
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
72-
restore-keys: |
73-
${{ runner.os }}-playwright-
74-
75-
- run: pnpm exec playwright install
76-
77-
- uses: nrwl/nx-set-shas@v4
78-
79-
- name: setup pnpm config
80-
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
56+
pnpm-cache-folder: .pnpm-store
8157

8258
- run: pnpm exec nx affected -t build lint test e2e-ci
8359

@@ -107,39 +83,20 @@ jobs:
10783
- run: pnpm pkg-pr-new publish './packages/*' './packages/sdk-effects/*' --packageManager=pnpm --comment=off
10884
if: steps.changesets.outputs.published == 'false'
10985

110-
- name: Send GitHub Action data to a Slack workflow
86+
- name: Publish Release Steps
11187
if: steps.changesets.outputs.published == 'true'
112-
uses: slackapi/slack-github-action@v2.1.1
88+
uses: ./.github/actions/publish-release
11389
with:
114-
payload-delimiter: '_'
115-
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
116-
webhook-type: webhook-trigger
117-
payload: $ {{ steps.changesets.outputs.publishedPackages }}
90+
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
91+
slackWebhook: ${{ secrets.SLACK_WEBHOOK_URL }}
11892

119-
- uses: codecov/codecov-action@v5
120-
with:
121-
files: ./packages/**/coverage/*.xml
122-
token: ${{ secrets.CODECOV_TOKEN }}
123-
124-
- name: Ensure builds run
125-
run: pnpm nx run-many -t build
126-
env:
127-
NX_CLOUD_DISTRIBUTED_EXECUTION: false
128-
129-
- name: Build docs
130-
run: pnpm generate-docs
131-
132-
- name: Publish api docs
133-
if: steps.changesets.outputs.published == 'true'
134-
uses: JamesIves/github-pages-deploy-action@v4.7.3
93+
- name: Publish Beta Steps
94+
if: steps.changesets.outputs.published == 'false'
95+
uses: ./.github/actions/publish-beta
13596
with:
136-
folder: docs
137-
commit-message: 'chore: release-api-docs'
97+
branch: main
13898

139-
- name: Publish api docs [beta]
140-
if: steps.changesets.outputs.published == 'false'
141-
id: latest-deploy
142-
uses: JamesIves/github-pages-deploy-action@v4.7.3
99+
- uses: JamesIves/github-pages-deploy-action@v4.7.3
143100
with:
144101
folder: docs
145102
commit-message: 'chore: release-api-docs-beta'

0 commit comments

Comments
 (0)