|
1 | 1 | name: Query help preview |
2 | 2 |
|
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
3 | 6 | on: |
4 | 7 | pull_request: |
5 | 8 | branches: |
6 | 9 | - main |
7 | | - - 'rc/*' |
| 10 | + - "rc/*" |
8 | 11 | paths: |
9 | 12 | - "ruby/**/*.qhelp" |
10 | 13 |
|
11 | 14 | jobs: |
12 | 15 | qhelp: |
13 | 16 | runs-on: ubuntu-latest |
14 | 17 | steps: |
| 18 | + - run: echo "${{ github.event.number }}" > pr.txt |
| 19 | + - uses: actions/upload-artifact@v2 |
| 20 | + with: |
| 21 | + name: comment |
| 22 | + path: pr.txt |
| 23 | + retention-days: 1 |
15 | 24 | - uses: actions/checkout@v2 |
16 | 25 | with: |
17 | 26 | fetch-depth: 2 |
| 27 | + persist-credentials: false |
| 28 | + - uses: ./.github/actions/fetch-codeql |
18 | 29 | - name: Determine changed files |
19 | 30 | id: changes |
20 | 31 | run: | |
21 | | - echo -n "::set-output name=qhelp_files::" |
22 | | - (git diff --name-only --diff-filter=ACMRT HEAD~1 HEAD | grep .qhelp$ | grep -v .inc.qhelp; |
23 | | - git diff --name-only --diff-filter=ACMRT HEAD~1 HEAD | grep .inc.qhelp$ | xargs -d '\n' -rn1 basename | xargs -d '\n' -rn1 git grep -l) | |
24 | | - sort -u | xargs -d '\n' -n1 printf "'%s' " |
25 | | -
|
26 | | - - uses: ./.github/actions/fetch-codeql |
| 32 | + (git diff -z --name-only --diff-filter=ACMRT HEAD~1 HEAD | grep -z '.qhelp$' | grep -z -v '.inc.qhelp'; |
| 33 | + git diff -z --name-only --diff-filter=ACMRT HEAD~1 HEAD | grep -z '.inc.qhelp$' | xargs --null -rn1 basename | xargs --null -rn1 git grep -z -l) | |
| 34 | + grep -z '.qhelp$' | grep -z -v '^-' | sort -z -u > "${RUNNER_TEMP}/paths.txt" |
27 | 35 |
|
28 | 36 | - name: QHelp preview |
29 | | - if: ${{ steps.changes.outputs.qhelp_files }} |
30 | 37 | run: | |
31 | | - ( echo "QHelp previews:"; |
32 | | - for path in ${{ steps.changes.outputs.qhelp_files }} ; do |
| 38 | + EXIT_CODE=0 |
| 39 | + echo "QHelp previews:" > comment.txt |
| 40 | + while read -r -d $'\0' path; do |
| 41 | + if [ ! -f "${path}" ]; then |
| 42 | + exit 1 |
| 43 | + fi |
33 | 44 | echo "<details> <summary>${path}</summary>" |
34 | 45 | echo |
35 | | - codeql generate query-help --format=markdown ${path} |
| 46 | + codeql generate query-help --format=markdown -- "./${path}" 2> errors.txt || EXIT_CODE="$?" |
| 47 | + if [ -s errors.txt ]; then |
| 48 | + echo "# errors/warnings:" |
| 49 | + echo '```' |
| 50 | + cat errors.txt |
| 51 | + cat errors.txt 1>&2 |
| 52 | + echo '```' |
| 53 | + fi |
36 | 54 | echo "</details>" |
37 | | - done) | gh pr comment "${{ github.event.pull_request.number }}" -F - |
38 | | - env: |
39 | | - GITHUB_TOKEN: ${{ github.token }} |
| 55 | + done < "${RUNNER_TEMP}/paths.txt" >> comment.txt |
| 56 | + exit "${EXIT_CODE}" |
| 57 | +
|
| 58 | + - if: always() |
| 59 | + uses: actions/upload-artifact@v2 |
| 60 | + with: |
| 61 | + name: comment |
| 62 | + path: comment.txt |
| 63 | + retention-days: 1 |
0 commit comments