-
Notifications
You must be signed in to change notification settings - Fork 6
237 lines (212 loc) · 9.39 KB
/
main.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: CI for WebHelp Contribution
on:
push:
branches:
- master
- zowe-v?-lts
pull_request_target:
workflow_dispatch:
inputs:
zowe-version:
description: "Specify the Zowe verison (vX.X.X)"
required: false
release:
description: "Create a release with the artifact"
default: false
required: true
type: boolean
jobs:
test:
runs-on: ubuntu-latest
if: (!contains(github.event.head_commit.message, '[ci skip]'))
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup .npmrc
id: setup-npmrc
run: npm config set @zowe:registry=https://zowe.jfrog.io/zowe/api/npm/npm-local-release/
- name: Install Node Package Dependencies
id: install-node
run: |
npm i --prod
npm install -g puppeteer-cli
- name: Install PIP Dependencies
id: install-pip
if: ${{ github.event.inputs.zowe-version && github.event.inputs.zowe-version != '' }}
run: pip3 install yq
- name: Set up Zowe from Versions
id: get-version-from-workflow
if: ${{ github.event.inputs.zowe-version && github.event.inputs.zowe-version != '' }}
run: |
curl -s https://raw.githubusercontent.com/zowe/zowe-cli-standalone-package/${{ github.event.inputs.zowe-version }}/master/zowe-versions.yaml > __zowe__version__
npm install -g @zowe/cli@$(yq '.packages.cli."zowe-v2-lts"' __zowe__version__ | tr -d '"')
zowe plugins install @zowe/cics-for-zowe-cli@$(yq '.packages."cics-for-zowe-cli"."zowe-v2-lts"' __zowe__version__ | tr -d '"')
zowe plugins install @zowe/db2-for-zowe-cli@$(yq '.packages."db2-for-zowe-cli"."zowe-v2-lts"' __zowe__version__ | tr -d '"')
zowe plugins install @zowe/ims-for-zowe-cli@$(yq '.packages."ims-for-zowe-cli"."zowe-v2-lts"' __zowe__version__ | tr -d '"')
zowe plugins install @zowe/mq-for-zowe-cli@$(yq '.packages."mq-for-zowe-cli"."zowe-v2-lts"' __zowe__version__ | tr -d '"')
zowe plugins install @zowe/zos-ftp-for-zowe-cli@$(yq '.packages."zos-ftp-for-zowe-cli"."zowe-v2-lts"' __zowe__version__ | tr -d '"')
rm __zowe__version__
- name: Set Up Zowe
id: setup-zowe
if: ${{ steps.get-version-from-workflow.outcome == 'skipped' }}
run: |
npm install -g @zowe/cli@zowe-v2-lts
zowe plugins install @zowe/cics-for-zowe-cli@zowe-v2-lts
zowe plugins install @zowe/db2-for-zowe-cli@zowe-v2-lts
zowe plugins install @zowe/ims-for-zowe-cli@zowe-v2-lts
zowe plugins install @zowe/mq-for-zowe-cli@zowe-v2-lts
zowe plugins install @zowe/zos-ftp-for-zowe-cli@zowe-v2-lts
- name: Get Zowe version
id: get-version
if: ${{ steps.get-version-from-workflow.outcome == 'skipped' }}
run: echo "number=$(echo 'CLI_v'$(npx zowe --version))" >> $GITHUB_OUTPUT
- name: Build Web Help
id: build
run: |
which zowe || true
zowe --version || true
npm run build:local -- ${{ github.event.inputs.zowe-version || steps.get-version.outputs.number }}
export margin="0.4in"
puppeteer print ./generatedWebHelp/docs/all.html ./zowe.pdf --margin-top $margin --margin-right $margin --margin-bottom $margin --margin-left $margin --no-sandbox
- name: Archive Results
id: upload
if: ${{ always() && steps.build.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: results
path: |
generatedWebHelp/
zowe.pdf
- name: Prepare Release Artifacts
id: release-prepare
if: ${{ github.ref_protected && steps.build.outcome == 'success' && github.event_name == 'workflow_dispatch' && github.event.inputs.zowe-version && github.event.inputs.zowe-version != '' && github.event.inputs.release == 'true' }}
run: |
mkdir release
mv zowe.pdf release/.
mv generatedWebHelp release/.
cd release
mv "generatedWebHelp" "zowe-${{ github.event.inputs.zowe-version }}-WebHelp"
mv "zowe.pdf" "zowe-${{ github.event.inputs.zowe-version }}.pdf"
TZ=UTC find . -exec touch -t 197001010000.00 {} +
zip -roX "zowe-${{ github.event.inputs.zowe-version }}-WebHelp.zip" "zowe-${{ github.event.inputs.zowe-version }}-WebHelp"
TZ=UTC touch -t 197001010000.00 zowe-${{ github.event.inputs.zowe-version }}-WebHelp.zip
- name: Create Release
id: release-create
if: ${{ steps.release-prepare.outcome == 'success' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
-t "${{ github.event.inputs.zowe-version }}" \
-n "Zowe CLI Web-Help for Zowe Release ${{ github.event.inputs.zowe-version }}" \
${{ github.event.inputs.zowe-version }} \
release/zowe-${{ github.event.inputs.zowe-version }}.pdf \
release/zowe-${{ github.event.inputs.zowe-version }}-WebHelp.zip
deploy-release:
needs: test
runs-on: ubuntu-latest
if: ${{ needs.test.result == 'success' && github.event_name == 'workflow_dispatch' && github.ref_protected && github.event.inputs.zowe-version && github.event.inputs.zowe-version != '' && github.event.inputs.release == 'true' }}
permissions:
contents: write
steps:
- name: Checkout Pages Branch
uses: actions/checkout@v4
with:
ref: 'gh-pages'
- name: Get Release Contents
env:
GITHUB_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }}
run: |
gh release download ${{ github.event.inputs.zowe-version }} -p zowe-${{ github.event.inputs.zowe-version }}-WebHelp.zip
rm -rf docs/${{ github.event.inputs.zowe-version }}
mkdir -p docs/${{ github.event.inputs.zowe-version }}
unzip -nqq zowe-${{ github.event.inputs.zowe-version }}-WebHelp.zip -d docs/${{ github.event.inputs.zowe-version }}
mv docs/${{ github.event.inputs.zowe-version }}/zowe-${{ github.event.inputs.zowe-version }}-WebHelp/* docs/${{ github.event.inputs.zowe-version }}/.
rmdir docs/${{ github.event.inputs.zowe-version }}/zowe-${{ github.event.inputs.zowe-version }}-WebHelp/
rm zowe-${{ github.event.inputs.zowe-version }}-WebHelp.zip
git config --global user.name ${{ secrets.ZOWE_ROBOT_USER }}
git config --global user.email ${{ secrets.ZOWE_ROBOT_EMAIL }}
git add docs/${{ github.event.inputs.zowe-version }}
git commit -sm "Add Zowe Web Help ${{ github.event.inputs.zowe-version }}"
git push origin HEAD
gh workflow run -r gh-pages deploy-pages.yml
deploy-artifact:
needs: test
runs-on: ubuntu-latest
if: needs.test.result == 'success' && github.event_name == 'push' && github.ref_protected
permissions:
contents: write
steps:
- name: Checkout Pages Branch
uses: actions/checkout@v4
with:
ref: 'gh-pages'
- name: Create directory
run: |
rm -rf docs/${{ github.ref_name }}
mkdir -p docs/${{ github.ref_name }}
- name: Get Artifact
uses: actions/download-artifact@v4
with:
name: results
path: docs/${{ github.ref_name }}
- name: Resolve Artifact
env:
GITHUB_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }}
run: |
mv docs/${{ github.ref_name }}/generatedWebHelp/* docs/${{ github.ref_name }}/.
rmdir docs/${{ github.ref_name }}/generatedWebHelp
rm docs/${{ github.ref_name }}/zowe.pdf
git config --global user.name ${{ secrets.ZOWE_ROBOT_USER }}
git config --global user.email ${{ secrets.ZOWE_ROBOT_EMAIL }}
git add docs/${{ github.ref_name }}
git commit -sm "Add Zowe Web Help for ${{ github.ref_name }}"
git push origin HEAD
gh workflow run -r gh-pages deploy-pages.yml
deploy-pr:
needs: test
runs-on: ubuntu-latest
if: needs.test.result == 'success' && github.event_name == 'pull_request_target'
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout Pages Branch
uses: actions/checkout@v4
with:
ref: 'gh-pages'
- name: Create directory
run: |
rm -rf docs/pr-${{github.event.number}}
mkdir -p docs/pr-${{github.event.number}}
- name: Get Artifact
uses: actions/download-artifact@v4
with:
name: results
path: docs/pr-${{ github.event.number }}
- name: Resolve Artifact
env:
GITHUB_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }}
run: |
mv docs/pr-${{ github.event.number }}/generatedWebHelp/* docs/pr-${{ github.event.number }}/.
rmdir docs/pr-${{ github.event.number }}/generatedWebHelp
rm docs/pr-${{ github.event.number }}/zowe.pdf
git config --global user.name ${{ secrets.ZOWE_ROBOT_USER }}
git config --global user.email ${{ secrets.ZOWE_ROBOT_EMAIL }}
git add docs/pr-${{ github.event.number }}
git commit -sm "Add Zowe Web Help for PR ${{ github.event.number }}"
git push origin HEAD
gh workflow run -r gh-pages deploy-pages.yml
- name: Comment on PR
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ github.event.number }}
message: "Changes will be available soon at <https://zowe.github.io/zowe-cli-web-help-generator/pr-${{ github.event.number }}>"