From 689164d2c008c17a39bca909aea423ddd5b52443 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Tue, 2 Nov 2021 20:33:05 +0000 Subject: [PATCH] chore: Create separate report_clang_format workflow in master branch (#5670) The initial version of this workflow just uses `console.log` to report the context of the `context` object. It is hoped that there will be enough information in this context to identify the PR to comment on, without the `check_clang_format` workflow having to upload a 'build artefact' of some kind - see example of what I hoe to avoid starting at `ReceivePR.yml` here: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ A follow-up PR will (if possible) add the code to create comments when `check_clang_format` fails. Part of #5659. --- .github/workflows/report_clang_format.yml | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/report_clang_format.yml diff --git a/.github/workflows/report_clang_format.yml b/.github/workflows/report_clang_format.yml new file mode 100644 index 000000000..11500bdcc --- /dev/null +++ b/.github/workflows/report_clang_format.yml @@ -0,0 +1,31 @@ +name: Report clang format + +# Runs after the Check clang format workflow (check_clang_format.yml) to +# post a helpful comment to the PR if the check failed. +# +# N.B.: Per https://github.community/t/workflow-runs-not-starting-after-previous-workflow-completes/128345/8 +# only the version of this workflow on the master (default) branch +# will be run, regardless of what branch is targetted by the PR being +# checked by check_clang_format.yml. +# +# N.B.: Runs with a read-write repo token. Do not check out the +# submitted branch! +on: + workflow_run: + workflows: ["Check clang format"] + types: + - completed + +on: [pull_request] + +jobs: + on-failure: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - uses: actions/github-script@v5 + with: + script: | + // Not sure yet how to find out which PR triggered the run, so + // dump the whole context object to try to find useful information. + console.log('%o', context);