name: Query help preview permissions: contents: read on: pull_request: branches: - main - "rc/*" paths: - "ruby/**/*.qhelp" jobs: qhelp: runs-on: ubuntu-latest steps: - run: echo "${{ github.event.number }}" > pr.txt - uses: actions/upload-artifact@v2 with: name: comment path: pr.txt retention-days: 1 - uses: actions/checkout@v2 with: fetch-depth: 2 persist-credentials: false - uses: ./.github/actions/fetch-codeql - name: Determine changed files id: changes run: | (git diff -z --name-only --diff-filter=ACMRT HEAD~1 HEAD | grep -z '.qhelp$' | grep -z -v '.inc.qhelp'; 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) | grep -z '.qhelp$' | grep -z -v '^-' | sort -z -u > "${RUNNER_TEMP}/paths.txt" - name: QHelp preview run: | EXIT_CODE=0 echo "QHelp previews:" > comment.txt while read -r -d $'\0' path; do if [ ! -f "${path}" ]; then exit 1 fi echo "
${path}" echo codeql generate query-help --format=markdown -- "./${path}" 2> errors.txt || EXIT_CODE="$?" if [ -s errors.txt ]; then echo "# errors/warnings:" echo '```' cat errors.txt cat errors.txt 1>&2 echo '```' fi echo "
" done < "${RUNNER_TEMP}/paths.txt" >> comment.txt exit "${EXIT_CODE}" - if: always() uses: actions/upload-artifact@v2 with: name: comment path: comment.txt retention-days: 1