Skip to content

Commit 7c15a44

Browse files
authored
cd: add canary deploy (#3044)
* cd: add canary deploy * chore: adjust workflow name * chore: ignore all `website` commits
1 parent 66b57e9 commit 7c15a44

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.github/workflows/canary.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: 'Canary Publishing'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
id-token: write
13+
14+
jobs:
15+
canary:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 15
18+
name: Canary
19+
steps:
20+
- name: Actions - Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Check Commit Message
26+
id: check_commit
27+
run: |
28+
MESSAGE=$(git log -1 --pretty=%s --no-merges)
29+
echo "Commit message: $MESSAGE"
30+
31+
if [[ "$MESSAGE" =~ build\(deps-dev\) ]] ||
32+
[[ "$MESSAGE" =~ build\(deps\) ]] ||
33+
[[ "$MESSAGE" =~ chore\(master\) ]] ||
34+
[[ "$MESSAGE" =~ chore\(deps\) ]] ||
35+
[[ "$MESSAGE" =~ chore:\ update\ dependencies ]] ||
36+
[[ "$MESSAGE" =~ docs: ]] ||
37+
[[ "$MESSAGE" =~ ci: ]] ||
38+
[[ "$MESSAGE" =~ cd: ]] ||
39+
[[ "$MESSAGE" =~ docs\(.*\): ]] ||
40+
[[ "$MESSAGE" =~ ci\(.*\): ]] ||
41+
[[ "$MESSAGE" =~ cd\(.*\): ]] ||
42+
[[ "$MESSAGE" =~ chore\(website\) ]]; then
43+
echo "publish=false" >> $GITHUB_OUTPUT
44+
echo "Skip publish"
45+
else
46+
echo "publish=true" >> $GITHUB_OUTPUT
47+
fi
48+
49+
- name: Actions - Setup Node.js
50+
if: steps.check_commit.outputs.publish == 'true'
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: '22.x'
54+
registry-url: 'https://registry.npmjs.org'
55+
56+
- name: Cache dependencies
57+
if: steps.check_commit.outputs.publish == 'true'
58+
uses: actions/cache@v4
59+
with:
60+
path: ~/.npm
61+
key: npm-linux-${{ hashFiles('package-lock.json') }}
62+
restore-keys: npm-linux-
63+
64+
- name: Installing Dependencies
65+
if: steps.check_commit.outputs.publish == 'true'
66+
run: npm ci
67+
68+
- name: Git Hash
69+
if: steps.check_commit.outputs.publish == 'true'
70+
run: |
71+
npm version patch --no-git-tag-version
72+
VERSION=$(node -p "require('./package.json').version")
73+
SHORT_SHA=$(git rev-parse --short HEAD)
74+
echo "VERSION=${VERSION}-canary.${SHORT_SHA}" >> $GITHUB_ENV
75+
76+
- name: Increment Canary Version
77+
if: steps.check_commit.outputs.publish == 'true'
78+
run: npm version $VERSION --no-git-tag-version
79+
80+
- name: Publishing Package
81+
if: steps.check_commit.outputs.publish == 'true'
82+
env:
83+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
84+
run: npm publish --tag canary --provenance

0 commit comments

Comments
 (0)