|
53 | 53 | -e TZ=UTC \ |
54 | 54 | ghcr.io/oneapi-src/spec-build:latest \ |
55 | 55 | python3 ./run.py --debug '--!build' --ver $VER |
| 56 | + - name: Determine if there is a diff between header files |
| 57 | + id: include-diff |
| 58 | + run: | #bash |
| 59 | + if git diff --quiet --exit-code -- spec-head/include spec-base/include; then |
| 60 | + echo "diff=0" >> $GITHUB_OUTPUT |
| 61 | + else |
| 62 | + echo "diff=1" >> $GITHUB_OUTPUT |
| 63 | + fi |
| 64 | + - name: Get header diff |
| 65 | + if: steps.include-diff.outputs.diff == '1' |
| 66 | + run: git diff --no-index spec-base/include spec-head/include > header-diff.patch || true |
| 67 | + - name: Write comment with formatting to DIFF_COMMENT |
| 68 | + if: steps.include-diff.outputs.diff == '1' |
| 69 | + shell: python3 {0} |
| 70 | + run: | |
| 71 | + import os |
| 72 | + with open('header-diff.patch', 'r') as f: |
| 73 | + diff_content = f.read() |
| 74 | + diff_comment = f"```diff\n{diff_content}\n```" |
| 75 | + # https://trstringer.com/github-actions-multiline-strings/#option-2---environment-variable |
| 76 | + with open(os.environ['GITHUB_ENV'], 'a') as env: |
| 77 | + print('RESULTS_COMMENT<<EOF', file = env) |
| 78 | + print(diff_comment, file = env) |
| 79 | + print('EOF', file = env) |
| 80 | + - name: Write comment to PR |
| 81 | + uses: actions/github-script@v6 |
| 82 | + if: steps.include-diff.outputs.diff == '1' |
| 83 | + with: |
| 84 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + script: | |
| 86 | + [, pullRequestId] = /refs\/pull\/(\d+)\/merge/g.exec(context.ref); |
| 87 | + github.rest.issues.createComment({ |
| 88 | + issue_number: pullRequestId, |
| 89 | + owner: context.repo.owner, |
| 90 | + repo: context.repo.repo, |
| 91 | + body: process.env.RESULTS_COMMENT |
| 92 | + }); |
| 93 | + - name: Write job summary |
| 94 | + if: steps.include-diff.outputs.diff == '1' |
| 95 | + run: echo "${RESULTS_COMMENT}" >> ${GITHUB_STEP_SUMMARY} |
56 | 96 | - name: Checkout loader-head |
57 | 97 | uses: actions/checkout@v4 |
58 | 98 | with: |
|
0 commit comments