Upgrades GitHub actions to current latest versions. #519
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
# This workflow will do a clean install of Node dependencies and execute all | |
# Bazel tests. This implicitly builds all required targets. Any target that is | |
# not tested but should verify its build should use a build test. | |
# https://github.com/bazelbuild/bazel-skylib/blob/master/rules/build_test.bzl | |
name: CI | |
on: | |
push: | |
branches: | |
# Run CI for direct pushes to `main`. I probably shouldn't do that in | |
# general, but for a core team of 1, PRs are a waste of effort. | |
- main | |
# Run CI for the `ci` branch. This branch isn't special in any way, it | |
# just does not enforce linear history, so edits to the CI workflow can be | |
# tested there where commits can still be amended before they are | |
# immutably pushed to main. | |
- ci | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test: | |
# Includes `bazelisk`. | |
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#:~:text=Bazel%204.2.1-,Bazelisk,-1.10.1 | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Bazel | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/bazel | |
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }} | |
restore-keys: | | |
${{ runner.os }}-bazel- | |
- name: Get pnpm store directory | |
id: pnpm-cache-dir | |
run: | | |
echo "PNPM_STORE_PATH=$(bazel run @pnpm --config ci -- store path --silent)" >> "${GITHUB_OUTPUT}" | |
- name: Cache pnpm | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.pnpm-cache-dir.outputs.PNPM_STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install | |
run: bazel run @pnpm --config ci -- install --dir $PWD --frozen-lockfile | |
# Build and test the entire repository. | |
- name: Test | |
run: | | |
# Run `bazel test //...` over all workspaces in the repository. | |
find . -name WORKSPACE.bazel -printf "%h\n" | | |
sort | | |
xargs -I {} bash -c "(cd {} && bazel test //... --config ci)" | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bazel.profile.gz | |
path: bazel.profile.gz | |
docs-deploy: | |
# Includes `bazelisk`. | |
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#:~:text=Bazel%204.2.1-,Bazelisk,-1.10.1 | |
runs-on: ubuntu-20.04 | |
# Only deploy after a successful test run. | |
needs: [test] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Bazel | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/bazel | |
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }} | |
restore-keys: | | |
${{ runner.os }}-bazel- | |
- name: Get pnpm store directory | |
id: pnpm-cache-dir | |
run: | | |
echo "PNPM_STORE_PATH=$(bazel run @pnpm --config ci -- store path --silent)" >> "${GITHUB_OUTPUT}" | |
- name: Cache pnpm | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.pnpm-cache-dir.outputs.PNPM_STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install | |
run: bazel run @pnpm --config ci -- install --dir $PWD --frozen-lockfile | |
- name: Deploy to preview | |
# Only publish non-`main` branch for preview. | |
if: ${{ github.ref_name != 'main' }} | |
run: | | |
bazel run //docs:deploy --config ci -- \ | |
--alias ${{ github.ref_name }} \ | |
-m "Automated preview deployment from GitHub actions." | |
env: | |
NETLIFY_SITE_ID: ${{ secrets.DOCS_NETLIFY_SITE_ID }} | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_PAT }} | |
- name: Deploy to Prod | |
# Only publish the `main` branch to prod. | |
if: ${{ github.ref_name == 'main' }} | |
run: | | |
bazel run //docs:deploy --config ci -- \ | |
--prod \ | |
-m "Automated prod deployment from GitHub actions." | |
env: | |
NETLIFY_SITE_ID: ${{ secrets.DOCS_NETLIFY_SITE_ID }} | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_PAT }} |