|
| 1 | +# Copyright (c) ONNX Project Contributors |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +name: PR Checks Comment |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_run: |
| 9 | + workflows: ["PR Checks"] |
| 10 | + types: |
| 11 | + - completed |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + suggest-changes: |
| 18 | + name: Suggest fixes |
| 19 | + runs-on: ubuntu-latest |
| 20 | + if: github.event.workflow_run.event == 'pull_request' |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + pull-requests: write |
| 24 | + steps: |
| 25 | + - name: Download artifacts |
| 26 | + id: download |
| 27 | + uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 |
| 28 | + continue-on-error: true |
| 29 | + with: |
| 30 | + name: pr-artifacts |
| 31 | + path: pr_artifacts/ |
| 32 | + run-id: ${{ github.event.workflow_run.id }} |
| 33 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + - name: Get PR number |
| 35 | + if: steps.download.outcome == 'success' |
| 36 | + id: pr |
| 37 | + run: echo "number=$(cat pr_artifacts/pr_number)" >> "$GITHUB_OUTPUT" |
| 38 | + - name: Check if diff is empty |
| 39 | + if: steps.download.outcome == 'success' |
| 40 | + id: diff |
| 41 | + run: | |
| 42 | + if [ -s pr_artifacts/lintrunner.diff ]; then |
| 43 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 44 | + else |
| 45 | + echo "has_changes=false" >> "$GITHUB_OUTPUT" |
| 46 | + fi |
| 47 | + - name: Checkout PR |
| 48 | + if: steps.download.outcome == 'success' && steps.diff.outputs.has_changes == 'true' |
| 49 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 50 | + with: |
| 51 | + ref: refs/pull/${{ steps.pr.outputs.number }}/head |
| 52 | + persist-credentials: false |
| 53 | + - name: Apply lintrunner fixes |
| 54 | + if: steps.download.outcome == 'success' && steps.diff.outputs.has_changes == 'true' |
| 55 | + run: git apply pr_artifacts/lintrunner.diff |
| 56 | + - name: Suggest changes |
| 57 | + if: steps.download.outcome == 'success' && steps.diff.outputs.has_changes == 'true' |
| 58 | + uses: parkerbxyz/suggest-changes@bd099ea0d10f0e9efeb9e46d604bbe6d7a80bc34 |
| 59 | + with: |
| 60 | + comment: 'You can commit the suggested changes from lintrunner.' |
0 commit comments