clippy-command #2
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: Run Clippy on PR | |
| on: | |
| repository_dispatch: | |
| types: [clippy-command] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| clippy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Resolve PR head | |
| id: pr | |
| run: | | |
| echo "repo=${{ github.event.client_payload.pull_request.head.repo.full_name }}" >> "$GITHUB_OUTPUT" | |
| echo "ref=${{ github.event.client_payload.pull_request.head.ref }}" >> "$GITHUB_OUTPUT" | |
| echo "number=${{ github.event.client_payload.pull_request.number }}" >> "$GITHUB_OUTPUT" | |
| - name: Set token | |
| id: token | |
| run: | | |
| if [ -n "${{ secrets.REPO_SCOPED_TOKEN }}" ]; then | |
| echo "token=${{ secrets.REPO_SCOPED_TOKEN }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "token=${{ secrets.GITHUB_TOKEN }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Checkout PR head | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ steps.pr.outputs.repo }} | |
| ref: ${{ steps.pr.outputs.ref }} | |
| token: ${{ steps.token.outputs.token }} | |
| fetch-depth: 0 | |
| - name: Install Rust (stable + clippy) | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| - name: Run cargo clippy | |
| id: clippy | |
| run: | | |
| set +e | |
| cargo clippy --all-targets --no-deps -- -D warnings > clippy_output.txt 2>&1 | |
| status=$? | |
| echo "status=$status" >> $GITHUB_OUTPUT | |
| exit 0 | |
| - name: Upload Clippy output | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: clippy-log | |
| path: clippy_output.txt | |
| - name: Comment results on PR | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| token: ${{ steps.token.outputs.token }} | |
| issue-number: ${{ steps.pr.outputs.number }} | |
| body: | | |
| 🧹 `cargo clippy` has completed on `${{ steps.pr.outputs.ref }}`. | |
| ${{ steps.clippy.outputs.status == '0' && '✅ No issues found!' || '⚠️ Warnings or errors detected – see Clippy log artifact.' }} |