-
Notifications
You must be signed in to change notification settings - Fork 2
186 lines (184 loc) · 6.86 KB
/
ci.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
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
181
182
183
184
185
name: Continuous Integration
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x ]
outputs:
srversion: ${{ steps.setoutput.outputs.srversion }}
srrelease: ${{ steps.setoutput.outputs.srrelease }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false # Make sure the release step uses its own credentials.
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
registry-url: 'https://npm.pkg.github.com/'
scope: '@zbmed'
- name: Run npm clean install
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.TREEVIEW_SECRET }}
- name: Run npm build
run: npm run build --if-present
env:
NODE_AUTH_TOKEN: ${{ secrets.TREEVIEW_SECRET }}
- name: Run semantic release and capture output
id: semantic_release
run: |
output=$(npx semantic-release)
sanitized_output=$(echo "$output" | tr '\n' ' ')
echo "release_output=$sanitized_output" >> $GITHUB_OUTPUT
echo "$output"
env:
GITHUB_TOKEN: ${{ secrets.PAT_TO_PUSH }}
NODE_AUTH_TOKEN: ${{ secrets.PAT_TO_PUSH }}
SCOPE: '@ts4nfdi'
- name: Capture version number
run: |
echo "SRVERSION=$(echo "${{ steps.semantic_release.outputs.release_output }}" | grep -oP 'Published release \K\d+\.\d+\.\d+')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.PAT_TO_PUSH }}
NODE_AUTH_TOKEN: ${{ secrets.PAT_TO_PUSH }}
SCOPE: '@ts4nfdi'
- name: Capture semantic-release
run: |
if echo "${{ steps.semantic_release.outputs.release_output }}" | grep -q 'Published release'; then
echo "SRRELEASE=release" >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.PAT_TO_PUSH }}
NODE_AUTH_TOKEN: ${{ secrets.PAT_TO_PUSH }}
SCOPE: '@ts4nfdi'
- name: Set output
id: setoutput
run: |
echo "srversion=$SRVERSION" >> "$GITHUB_OUTPUT"
echo "srrelease=$SRRELEASE" >> "$GITHUB_OUTPUT"
- name: Debug SRVERSION
run: echo "SRVERSION is $SRVERSION"
- name: Debug SRRELEASE
run: echo "SRRELEASE is $SRRELEASE"
- name: Run npm build:plainJS
run: npm run build:plainJS
- name: Set Git Author Identity
if: env.SRRELEASE == 'release'
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Configure Git to Use PAT for Authentication
if: env.SRRELEASE == 'release'
run: |
git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n '${{ secrets.GH_PAT }}' | base64)"
- name: Upload artifact
if: env.SRRELEASE == 'release'
uses: actions/upload-pages-artifact@v1
with:
path: dist_plainjs
- name: Copy as Latest to gh-pages
if: env.SRRELEASE == 'release'
run: |
npx gh-pages-multi deploy -s dist_plainjs --no-history -t js-modules/latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Copy Version to gh-pages
if: env.SRRELEASE == 'release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx gh-pages-multi deploy -s dist_plainjs --no-history -t js-modules/"$SRVERSION"
documentation:
if: github.ref == 'refs/heads/main' && needs.build.outputs.srrelease == 'release'
needs: build
runs-on: ubuntu-latest
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://npm.pkg.github.com/'
scope: '@zbmed'
token: ${{ secrets.TREEVIEW_SECRET }}
- name: Run npm clean install
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.TREEVIEW_SECRET }}
- name: Run npm build:plainJS
run: npm run build:plainJS
- name: Install and Build HTML Storybook
run: |
npm install
npm run build-storybook-html -- -o html
env:
NODE_AUTH_TOKEN: ${{ secrets.TREEVIEW_SECRET }}
- name: Upload html artifact
uses: actions/upload-pages-artifact@v1
with:
path: 'html'
- name: Install and Build React Storybook
run: |
npm install
npm run build-storybook-react -- -o react
env:
NODE_AUTH_TOKEN: ${{ secrets.TREEVIEW_SECRET }}
- name: Upload react artifact
uses: actions/upload-pages-artifact@v1
with:
path: 'react'
- name: Install and Build Composed Storybook
run: |
npm install
npm run build-storybook -- -o public
env:
NODE_AUTH_TOKEN: ${{ secrets.TREEVIEW_SECRET }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: 'public'
- name: Set Git Author Identity
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Configure Git to Use PAT for Authentication
run: |
git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n '${{ secrets.GH_PAT }}' | base64)"
- name: Use SRVERSION
env:
SRVERSION: ${{ needs.build.outputs.srversion }}
run: echo "SRVERSION is $SRVERSION"
- name: Deploy as Latest to GitHub Pages
if: env.SRVERSION != ''
env:
SRVERSION: ${{ needs.build.outputs.srversion }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx gh-pages-multi deploy -s react --no-history -t react/latest
npx gh-pages-multi deploy -s html --no-history -t html/latest
npx gh-pages-multi deploy -s public --no-history -t comp/latest
- name: Deploy Version to GitHub Pages
if: env.SRVERSION != ''
env:
SRVERSION: ${{ needs.build.outputs.srversion }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx gh-pages-multi deploy -s react --no-history -t react/"$SRVERSION"
npx gh-pages-multi deploy -s html --no-history -t html/"$SRVERSION"
npx gh-pages-multi deploy -s public --no-history -t comp/"$SRVERSION"