From db71a458e48197dc4d7bd15d8e8d96cef9b87f73 Mon Sep 17 00:00:00 2001 From: Samuel Burnham <45365069+samuelburnham@users.noreply.github.com> Date: Thu, 26 Oct 2023 11:07:03 -0400 Subject: [PATCH] Add test command in PR comment (#9) --- .github/workflows/pr-comment.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/pr-comment.yml diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml new file mode 100644 index 00000000..a9c7fa20 --- /dev/null +++ b/.github/workflows/pr-comment.yml @@ -0,0 +1,39 @@ +name: PR comment test + +on: + issue_comment: + types: [created] + +env: + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + run-test: + name: run test + runs-on: ubuntu-latest + if: + github.event.issue.pull_request + && github.event.issue.state == 'open' + && contains(github.event.comment.body, '!test') + && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') + steps: + - uses: xt0rted/pull-request-comment-branch@v2 + id: comment-branch + - uses: actions/checkout@v4 + - name: Checkout PR branch + run: gh pr checkout ${{ github.event.issue.number }} + env: + # TODO: Remove if not needed + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check private key exists + # Potential alternative: https://github.com/myrotvorets/set-commit-status-action + uses: actions/github-script@v6 + with: + script: | + if ("$PRIVATE_KEY" == "") { + core.setFailed('Failed to access PRIVATE_KEY secret') + } \ No newline at end of file