HAR Viewer Deployer #16
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: HAR Viewer Deployer | |
on: | |
workflow_dispatch: | |
inputs: | |
pages_branch: | |
description: "GitHub Pages branch" | |
required: true | |
default: "gh-pages" | |
type: choice | |
options: | |
- "gh-pages" | |
- "gh-pages-test" | |
jobs: | |
deploy: | |
runs-on: ubuntu-20.04 | |
env: | |
NODE_ENV: production | |
PAGES_BRANCH: ${{ inputs.pages_branch }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build:prod -- --base-href=/har-viewer/ | |
- name: Set up GitHub Pages repository | |
run: | | |
mkdir output | |
git config --global user.email "[email protected]" | |
git config --global user.name "${GITHUB_ACTOR}" | |
git clone https://${{ secrets.ACCESS_TOKEN }}@github.com/sunriselink/har-viewer.git --branch ${PAGES_BRANCH} --single-branch ./output | |
- name: Deploy | |
working-directory: output | |
run: | | |
git rm -rfq . | |
cp -rv ../dist/har-viewer/browser/** . | |
cp -v ../dist/har-viewer/3rdpartylicenses.txt . | |
git add --all | |
git commit -m "Update $(date +'%Y-%m-%d %H:%M:%S %:z')" | |
git push | |
- name: Send Telegram Notification | |
run: | | |
VERSION=$(node -p "require('./package').version") | |
METHOD="https://api.telegram.org/bot${{ secrets.TG_BOT_TOKEN }}/sendMessage" | |
TEXT="HAR Viewer v${VERSION} deployed by ${GITHUB_ACTOR}" | |
ADMIN_ID="${{ secrets.TG_ADMIN_ID }}" | |
curl -s -o /dev/null -X POST ${METHOD} -d text="${TEXT}" -d chat_id=${ADMIN_ID} |