Deploy to GitHub Pages #1495
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 to GitHub Pages | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/deploy-website.yml' | |
| - 'website/**' | |
| workflow_run: | |
| workflows: | |
| - Garnet CI BDN.benchmark | |
| - Garnet Nightly Tests | |
| types: | |
| - completed | |
| permissions: | |
| contents: write | |
| actions: read | |
| jobs: | |
| deploy: | |
| if: always() | |
| name: Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: website | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: continuousbenchmark | |
| sparse-checkout: | | |
| website/static/charts | |
| path: continuousbenchmark | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: continuousbenchmark_net80 | |
| sparse-checkout: | | |
| website/static/charts | |
| path: continuousbenchmark_net80 | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: allure_data_history | |
| path: allure_data_history | |
| # Checkout gh-pages to preserve existing Allure content when not updating from Nightly | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| path: gh-pages-current | |
| - name: Copy charts | |
| run: | | |
| mkdir -p static/charts | |
| cp ../continuousbenchmark/website/static/charts/* static/charts | |
| cp ../continuousbenchmark_net80/website/static/charts/data.js static/charts/data_net80.js | |
| - name: DEBUG Show triggering workflow name | |
| run: echo ${{ github.event.workflow_run.name }} | |
| # When NOT triggered by Nightly, preserve existing Allure content from gh-pages | |
| - name: Preserve existing Allure from gh-pages | |
| if: ${{ github.event.workflow_run.name != 'Garnet Nightly Tests' }} | |
| run: | | |
| if [ -d "../gh-pages-current/allure" ]; then | |
| mkdir -p static/allure | |
| cp -R ../gh-pages-current/allure/* static/allure/ | |
| echo "Preserved existing Allure content from gh-pages" | |
| else | |
| echo "No existing Allure content found on gh-pages" | |
| fi | |
| # Download the current allure_report artifact which is big with A LOT of test result files | |
| # Nightly run does not put full allure_report up in the allure_data_history branch to keep that branch small | |
| - name: Download Allure artifact | |
| if: ${{ github.event.workflow_run.name == 'Garnet Nightly Tests' }} | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: allure-report | |
| path: allure_artifact | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ github.token }} | |
| # The one thing that is pulled from allure_data_history branch is the historical test result data | |
| # This data is then copied into the downloaded allure_report to create a full report with history | |
| - name: Copy Allure report | |
| if: ${{ github.event.workflow_run.name == 'Garnet Nightly Tests' }} | |
| run: | | |
| mkdir -p static/allure | |
| # Base: Allure full report from Nightly Run artifact | |
| # Note: artifact downloads to workspace root, not working-directory, so use ../ | |
| # The artifact contents are directly in allure_artifact/ (not in a nested allure-report folder) | |
| if [ -d "../allure_artifact" ]; then | |
| cp -R ../allure_artifact/* static/allure | |
| echo "Copied Allure report from artifact" | |
| else | |
| echo "Allure artifact missing; skipping base report copy." | |
| fi | |
| # Overlay: history from branch | |
| if [ -d "../allure_data_history/test/Allure/history" ]; then | |
| cp -R ../allure_data_history/test/Allure/history static/allure/history | |
| else | |
| echo "Allure history missing; skipping history overlay." | |
| fi | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: yarn | |
| cache-dependency-path: ./website/yarn.lock | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build website | |
| run: yarn build | |
| # Popular action to deploy to GitHub Pages: | |
| # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e #v4 - for security reasons have pinned tag (commit SHA) for 3rd party | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| # Build output to publish to the `gh-pages` branch: | |
| publish_dir: ./website/build | |
| # Deploy as an orphan commit (single commit, no history) to prevent | |
| # the gh-pages branch from accumulating large generated files (charts, | |
| # allure reports, search index) across hundreds of commits, which | |
| # bloats the repository pack file and slows down git clone. | |
| force_orphan: true | |
| # The following lines assign commit authorship to the official | |
| # GH-Actions bot for deploys to `gh-pages` branch: | |
| # https://github.com/actions/checkout/issues/13#issuecomment-724415212 | |
| # The GH actions bot is used by default if you didn't specify the two fields. | |
| # You can swap them out with your own user credentials. | |
| user_name: github-actions[bot] | |
| user_email: 41898282+github-actions[bot]@users.noreply.github.com |