Deploy Pages #36
This file contains hidden or 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: Deploy Pages | |
| # Triggered when the Release workflow completes successfully. | |
| # workflow_run ALWAYS executes on the default branch (main), so | |
| # GITHUB_REF is refs/heads/main — this passes the github-pages | |
| # environment protection rules that block tag/release-triggered workflows. | |
| on: | |
| workflow_run: | |
| workflows: ["Release"] | |
| types: [completed] | |
| workflow_dispatch: # allow manual re-deploy from the Actions UI without a release | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| deploy-pages: | |
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deploy.outputs.page_url }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Node dependencies | |
| run: npm install | |
| - name: Set version from release tag | |
| run: node scripts/set-version.js ${{ github.event.workflow_run.head_branch || 'main' }} | |
| - name: Build single-file bundle | |
| env: | |
| PEARTREE_VERSION_TAG: ${{ github.event.workflow_run.head_branch || 'main' }} | |
| run: npm run bundle | |
| - name: Build manual | |
| run: npm run build:manual | |
| - name: Assemble site | |
| run: | | |
| mkdir -p _site/data _site/img _site/logo _site/manual/images _site/settings _site/js | |
| cp peartree/index.html _site/index.html | |
| [ -f CNAME ] && cp CNAME _site/CNAME || true | |
| cp dist/peartree.bundle.min.js _site/peartree.bundle.min.js | |
| cp peartree/img/peartree.svg _site/img/peartree.svg | |
| cp peartree/img/peartree.png _site/img/peartree.png | |
| cp logo/peartree.svg _site/logo/peartree.svg | |
| cp logo/peartree.png _site/logo/peartree.png | |
| cp peartree/data/ebov.tree _site/data/ebov.tree | |
| cp peartree/data/VARV.tree _site/data/VARV.tree | |
| cp peartree/data/large_tree.tree _site/data/large_tree.tree | |
| cp peartree/data/SARS-CoV-2_15K.tree _site/data/SARS-CoV-2_15K.tree | |
| cp peartree/data/ebov.csv _site/data/ebov.csv | |
| cp peartree/about.md _site/about.md | |
| cp peartree/help.md _site/help.md | |
| cp peartree/settings/index.html _site/settings/index.html | |
| cp peartree/js/settings-schema.js _site/js/settings-schema.js | |
| cp peartree/js/config.js _site/js/config.js | |
| - name: Configure Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _site/ | |
| - name: Deploy to GitHub Pages | |
| id: deploy | |
| uses: actions/deploy-pages@v4 |