.github/workflows/pr-check.yml #15
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: 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: 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' | 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 }} |