Skip to content

Merge pull request #263 from mobusoperandi/default-branch-main #1051

Merge pull request #263 from mobusoperandi/default-branch-main

Merge pull request #263 from mobusoperandi/default-branch-main #1051

Workflow file for this run

on: [push, pull_request]
permissions:
contents: write
pull-requests: write
env:
RUST_BACKTRACE: 1
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update
- id: get-rust-version
run: echo "rust_version=$(rustc --version)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v3
with:
path: |
.bin/
target/
~/.cargo/
key: ${{ runner.os }}_${{ steps.get-rust-version.outputs.rust_version }}_${{ hashFiles('rust-toolchain.toml', 'Cargo.toml', 'Cargo.lock') }}
restore-keys: |
${{ runner.os }}_${{ steps.get-rust-version.outputs.rust_version }}_
${{ runner.os }}_
- run: npm ci
- run: ./git_hooks/pre-commit
- run: cargo run build
- name: no_untracked
run: |
set -euxo pipefail
if [[ `git ls-files --exclude-standard --others` ]]; then
echo "untracked files detected"
exit 1
fi
- name: no_modified
run: |
set -euxo pipefail
if ! git diff --exit-code; then
echo "modified files detected"
exit 1
fi
- id: get_output_dir
run: echo "output_dir=$(cargo run -- print-output-dir)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
with:
name: build_output_dir
path: ${{ steps.get_output_dir.outputs.output_dir }}
outputs:
output_dir: ${{ steps.get_output_dir.outputs.output_dir }}
deploy-preview:
if: github.event_name == 'pull_request'
needs: build
environment: pull_request_deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build_output_dir
path: ${{ needs.build.outputs.output_dir }}
- id: deploy
run: |
npx vercel pull --yes --environment=preview --scope mobusoperandi --token=${{ secrets.VERCEL_TOKEN }}
URL=$(npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
echo "URL=$URL" >> $GITHUB_OUTPUT
- uses: thollander/actions-comment-pull-request@v2
with:
message: |
Branch deployed for review at:
${{ steps.deploy.outputs.URL }}
deploy-production:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build_output_dir
path: ${{ needs.build.outputs.output_dir }}
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ needs.build.outputs.output_dir }}