|
| 1 | +name: Config Check |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + branches: ["main"] |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +permissions: |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + diff: |
| 17 | + runs-on: distroless-ci-large-ubuntu-22.04 |
| 18 | + steps: |
| 19 | + - name: Checkout PR Branch |
| 20 | + uses: actions/checkout@v5 |
| 21 | + with: |
| 22 | + ref: ${{ github.event.pull_request.head.sha }} |
| 23 | + path: pr_branch |
| 24 | + |
| 25 | + - name: Build :sign_and_push.query for PR |
| 26 | + run: | |
| 27 | + cd pr_branch |
| 28 | + bazel build :sign_and_push.query |
| 29 | + cp bazel-bin/sign_and_push_query ../pr_query_output.txt |
| 30 | + cd .. |
| 31 | +
|
| 32 | + - name: Checkout main Branch |
| 33 | + uses: actions/checkout@v5 |
| 34 | + with: |
| 35 | + ref: main |
| 36 | + path: main_branch |
| 37 | + |
| 38 | + - name: Build :sign_and_push.query for main |
| 39 | + run: | |
| 40 | + cd main_branch |
| 41 | + bazel build :sign_and_push.query |
| 42 | + cp bazel-bin/sign_and_push_query ../main_query_output.txt |
| 43 | + cd .. |
| 44 | +
|
| 45 | + - name: Diff the query outputs |
| 46 | + id: diff |
| 47 | + run: | |
| 48 | + # diff may exit with non-zero |
| 49 | + DIFF_OUTPUT=$(diff -u <(sort main_query_output.txt) <(sort pr_query_output.txt)) || true |
| 50 | + |
| 51 | + if [ "$DIFF_OUTPUT" ]; then |
| 52 | + echo "$DIFF_OUTPUT" |
| 53 | + echo "changed_build<<EOF" >> $GITHUB_OUTPUT |
| 54 | + echo "$DIFF_OUTPUT" >> $GITHUB_OUTPUT |
| 55 | + echo "EOF" >> $GITHUB_OUTPUT |
| 56 | + fi |
| 57 | +
|
| 58 | + - uses: peter-evans/find-comment@v4 |
| 59 | + id: fc |
| 60 | + if: ${{ !github.event.pull_request.head.repo.fork }} |
| 61 | + with: |
| 62 | + issue-number: ${{ github.event.pull_request.number }} |
| 63 | + comment-author: "github-actions[bot]" |
| 64 | + body-includes: 🌳 🔧 Config Check |
| 65 | + |
| 66 | + - name: Report diff |
| 67 | + if: ${{ !github.event.pull_request.head.repo.fork && steps.diff.outputs.changed_build }} |
| 68 | + uses: peter-evans/create-or-update-comment@v5 |
| 69 | + with: |
| 70 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 71 | + issue-number: ${{ github.event.pull_request.number }} |
| 72 | + body: | |
| 73 | + 🌳 🔧 Config Check |
| 74 | +
|
| 75 | + This pull request has modified the root BUILD |
| 76 | +
|
| 77 | + ```diff |
| 78 | + ${{steps.diff.outputs.changed_build}} |
| 79 | + ``` |
| 80 | + edit-mode: replace |
| 81 | + |
| 82 | + - name: Report no diff |
| 83 | + if: ${{ !github.event.pull_request.head.repo.fork && !steps.diff.outputs.changed_build }} |
| 84 | + uses: peter-evans/create-or-update-comment@v5 |
| 85 | + with: |
| 86 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 87 | + issue-number: ${{ github.event.pull_request.number }} |
| 88 | + body: | |
| 89 | + 🌳 🔧 Config Check |
| 90 | +
|
| 91 | + This pull request has not modified the root BUILD |
| 92 | + edit-mode: replace |
0 commit comments