-
Notifications
You must be signed in to change notification settings - Fork 10
71 lines (71 loc) · 2.57 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
on: [push, pull_request_target]
permissions:
contents: write
pull-requests: write
env:
RUST_BACKTRACE: 1
jobs:
ci:
environment: pull_request_deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
if: github.event_name == 'pull_request_target'
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@v3
if: github.event_name == 'push'
- 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 }}_cargo-run-bin_${{ hashFiles('rust-toolchain.toml', 'Cargo.toml', 'Cargo.lock') }}
restore-keys: |
${{ runner.os }}_${{ steps.get-rust-version.outputs.rust_version }}_cargo-run-bin_
${{ runner.os }}_${{ steps.get-rust-version.outputs.rust_version }}_
${{ runner.os }}_
- run: cargo install cargo-run-bin
- run: npm ci
- run: ./git_hooks/pre-commit
- run: cargo run --package builder
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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: deploy
if: github.event_name == 'pull_request_target'
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
- if: github.event_name == 'pull_request_target'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Branch deployed for review at:
${{ steps.deploy.outputs.URL }}
- id: get_output_dir
run: echo "OUTPUT_DIR=$(cargo run -- print-output-dir)" >> $GITHUB_OUTPUT
- uses: JamesIves/github-pages-deploy-action@v4
if: github.ref == 'refs/heads/master'
with:
folder: ${{ steps.get_output_dir.outputs.OUTPUT_DIR }}