-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
70 lines (62 loc) · 2.09 KB
/
pr-check.yml
File metadata and controls
70 lines (62 loc) · 2.09 KB
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
name: PR Check
on:
pull_request:
branches: [master]
paths:
- "data/tools/**.yml"
- "ci/**"
workflow_dispatch:
inputs:
pr_number:
description: "PR number to check"
required: true
tool_files:
description: "Space-separated list of tool YAML files to check (e.g. data/tools/foo.yml)"
required: true
jobs:
pr-check:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check out PR head for manual runs
if: github.event_name == 'workflow_dispatch'
run: |
git fetch origin "refs/pull/${{ inputs.pr_number }}/head"
git checkout FETCH_HEAD -- ${{ inputs.tool_files }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get changed tool files
id: changed
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
FILES="${{ inputs.tool_files }}"
else
FILES=$(git diff --name-only --diff-filter=A origin/master...HEAD -- 'data/tools/*.yml' 'data/tools/*.yaml' | tr '\n' ' ')
fi
echo "files=$FILES" >> "$GITHUB_OUTPUT"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
ci/target
key: pr-check-${{ runner.os }}-${{ hashFiles('ci/Cargo.lock') }}
restore-keys: |
pr-check-${{ runner.os }}-
- name: Build pr-check
run: cargo build --release --manifest-path ci/Cargo.toml -p pr-check
- name: Run pr-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || github.event.pull_request.number }}
run: |
ci/target/release/pr-check ${{ steps.changed.outputs.files }}