chore: store baseline results as artifacts (#105) #9
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_run: | |
| workflows: | |
| - baseline | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| actions: read | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| ref: ${{ github.event.repository.default_branch }} | |
| - name: find latest baseline run | |
| id: baseline | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }} | |
| run: | | |
| run_id="$WORKFLOW_RUN_ID" | |
| if [[ -z "$run_id" ]]; then | |
| run_id="$(gh run list \ | |
| --workflow baseline.yml \ | |
| --branch "${{ github.event.repository.default_branch }}" \ | |
| --status success \ | |
| --limit 1 \ | |
| --json databaseId \ | |
| --jq '.[0].databaseId // empty')" | |
| fi | |
| echo "run-id=$run_id" >> "$GITHUB_OUTPUT" | |
| - name: download baseline results | |
| if: steps.baseline.outputs.run-id != '' | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| pattern: baseline-${{ steps.baseline.outputs.run-id }}* | |
| merge-multiple: true | |
| run-id: ${{ steps.baseline.outputs.run-id }} | |
| github-token: ${{ github.token }} | |
| - name: merge baseline results | |
| if: steps.baseline.outputs.run-id != '' | |
| run: | | |
| shard_output="$(find results -type f -name 'output-*.json' -print -quit)" | |
| if [[ -z "$shard_output" ]]; then | |
| exit 0 | |
| fi | |
| output_directory="$(dirname "$shard_output")" | |
| jq --slurp ' | |
| . as $outputs | |
| | ([$outputs[].treatments[]] | unique_by(.config.name)) as $treatments | |
| | $outputs[0] | |
| | .treatments = $treatments | |
| | .results = [ | |
| $outputs[] as $output | |
| | $output.results[] | |
| | . as $result | |
| | ($output.treatments[] | select(.id == $result.treatmentId).config.name) as $name | |
| | .treatmentId = ($treatments[] | select(.config.name == $name).id) | |
| ] | |
| ' "$output_directory"/output-*.json > "$output_directory/output.json" | |
| - name: set up pnpm | |
| uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 | |
| - name: set up Node.js | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'pnpm' | |
| - name: restore turbo cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: .turbo | |
| key: turbo-${{ runner.os }}-${{ github.job }}-${{ github.sha }} | |
| restore-keys: | | |
| turbo-${{ runner.os }}-${{ github.job }}- | |
| - name: install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: configure GitHub Pages | |
| id: pages | |
| uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 | |
| - name: build project | |
| run: pnpm run build | |
| env: | |
| PAGES_BASE_PATH: ${{ steps.pages.outputs.base_path }} | |
| - name: upload GitHub Pages artifact | |
| uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 | |
| with: | |
| path: ./website/out | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 |