CI for WebHelp Contribution #2480
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-v3-lts"' __zowe__version__ | tr -d '"') | |
zowe plugins install @zowe/cics-for-zowe-cli@$(yq '.packages."cics-for-zowe-cli"."zowe-v3-lts"' __zowe__version__ | tr -d '"') | |
zowe plugins install @zowe/db2-for-zowe-cli@$(yq '.packages."db2-for-zowe-cli"."zowe-v3-lts"' __zowe__version__ | tr -d '"') | |
zowe plugins install @zowe/mq-for-zowe-cli@$(yq '.packages."mq-for-zowe-cli"."zowe-v3-lts"' __zowe__version__ | tr -d '"') | |
zowe plugins install @zowe/zos-ftp-for-zowe-cli@$(yq '.packages."zos-ftp-for-zowe-cli"."zowe-v3-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-v3-lts | |
zowe plugins install @zowe/cics-for-zowe-cli@zowe-v3-lts | |
zowe plugins install @zowe/db2-for-zowe-cli@zowe-v3-lts | |
zowe plugins install @zowe/mq-for-zowe-cli@zowe-v3-lts | |
zowe plugins install @zowe/zos-ftp-for-zowe-cli@zowe-v3-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 --rfj | jq -r .data.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 }}>" |