-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (150 loc) · 6.1 KB
/
deploy.yml
File metadata and controls
180 lines (150 loc) · 6.1 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Publish Release
on:
push:
branches: [main]
jobs:
setup:
if: "${{!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'Release: Version Updates')}}"
runs-on: ubuntu-latest
permissions:
actions: read
steps:
- name: Checkout Code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
fetch-depth: 0
ref: 'main'
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@826660b82addbef3abff5fa871492ebad618c9e1 # v4.3.3
- name: Set Node Version
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: |
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Restore yarn cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-24-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-24-yarn-
- name: Install Dependencies
run: yarn install --immutable
- name: Lint Affected Code
run: yarn lint:affected
- name: Unit Test Affected Code
run: yarn test:affected
publish:
if: "${{!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'Release: Version Updates')}}"
needs: [setup]
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.changes.outputs.has_changes }}
permissions:
contents: write # Required for git push and creating tags
pull-requests: write # Required for creating pull requests
id-token: write
steps:
- name: Checkout Code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
ref: 'main'
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@826660b82addbef3abff5fa871492ebad618c9e1 # v4.3.3
- name: Set Node Version
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
- name: Install latest npm
run: npm install -g npm@latest
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: |
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Restore yarn cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-24-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-24-yarn-
- name: Install Dependencies
run: yarn install --immutable
- name: Build Packages
run: yarn build
- name: Setup Publish Config
run: |
git config user.email ${{ secrets.GH_EMAIL }}
git config user.name ${{ secrets.GH_USER }}
- name: Store initial commit SHA
id: initial-sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Version Packages
run: |
yarn nx affected --target version --parallel=1
- name: Check for Version Changes
id: changes
run: |
INITIAL_SHA="${{ steps.initial-sha.outputs.sha }}"
CURRENT_SHA=$(git rev-parse HEAD)
if [ "$INITIAL_SHA" = "$CURRENT_SHA" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No new commits created by version step"
else
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "New commits created by version step"
fi
- name: Publish
if: steps.changes.outputs.has_changes == 'true'
run: |
yarn nx affected --target publish --parallel=1
- name: Create Release PR
if: steps.changes.outputs.has_changes == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Creating PR because changes detected: ${{ steps.changes.outputs.has_changes }}"
git push origin --delete release/version-updates || true
git checkout -b release/version-updates
git push origin release/version-updates
git push origin --tags
gh pr create --title "Release: Version Updates" --body "Automated release PR with version updates and package publications." --base main --head release/version-updates
deploy-docs:
if: "${{!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'Release: Version Updates')}}"
needs: [setup]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Set Node Version
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
- name: Install Dependencies
run: yarn install --immutable
- name: Build Packages
run: yarn build
- name: Build Docs
run: yarn build:storybook:ci
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: dist/storybook
keep_files: true
enable_jekyll: false