From c81a736137e227cc19c9bfedfbd218f1e18368f7 Mon Sep 17 00:00:00 2001 From: Sarah Dutkiewicz Date: Tue, 21 Mar 2023 11:59:18 -0400 Subject: [PATCH 1/2] Working through build issues for new contributors --- .github/workflows/comment-on-pr.yml | 40 +++++++++++++++++++++++++++++ .github/workflows/dotnetcore.yml | 22 +++++++++++++--- 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/comment-on-pr.yml diff --git a/.github/workflows/comment-on-pr.yml b/.github/workflows/comment-on-pr.yml new file mode 100644 index 0000000..cc4863d --- /dev/null +++ b/.github/workflows/comment-on-pr.yml @@ -0,0 +1,40 @@ +name: Comment on the Pull Request + +# read-write repo token +# See: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ +on: + workflow_run: + workflows: [".NET Core"] + types: + - completed + +jobs: + comment: + runs-on: ubuntu-latest + + # Only comment on the PR if this is a PR event + if: github.event.workflow_run.event == 'pull_request' + + steps: + - name: Get the PR Number artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + workflow_conclusion: "" + name: pr-number + - name: Read PR Number into GitHub environment variables + run: echo "PR_NUMBER=$(cat pr-number.txt)" >> $GITHUB_ENV + - name: Confirm the PR Number (Debugging) + run: echo $PR_NUMBER + - name: Get the code coverage results file + uses: dawidd6/action-download-artifact@v2 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + workflow_conclusion: "" + name: code-coverage-results + - name: Add Coverage PR Comment + uses: marocchino/sticky-pull-request-comment@v2 + with: + number: ${{ env.PR_NUMBER }} + recreate: true + path: code-coverage-results.md \ No newline at end of file diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 59e3d5f..62dcf1e 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -45,9 +45,23 @@ jobs: format: 'markdown' output: 'both' - - name: Add Coverage PR Comment - uses: marocchino/sticky-pull-request-comment@v2 - if: github.event_name == 'pull_request' + - name: Upload code coverage results artifact + uses: actions/upload-artifact@v3 + if: success() || failure() with: - recreate: true + name: code-coverage-results path: code-coverage-results.md + + - name: Save the PR number in an artifact + if: github.event_name == 'pull_request' && (success() || failure()) + shell: bash + env: + PR_NUMBER: ${{ github.event.number }} + run: echo $PR_NUMBER > pr-number.txt + + - name: Upload the PR number + uses: actions/upload-artifact@v3 + if: github.event_name == 'pull_request' && (success() || failure()) + with: + name: pr-number + path: ./pr-number.txt \ No newline at end of file From 6be17256e7d992f46c45bf953215c8dedf092efb Mon Sep 17 00:00:00 2001 From: Sarah Dutkiewicz Date: Tue, 21 Mar 2023 12:08:17 -0400 Subject: [PATCH 2/2] Adding retention period to artifacts --- .github/workflows/dotnetcore.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 62dcf1e..dfadea4 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -51,6 +51,7 @@ jobs: with: name: code-coverage-results path: code-coverage-results.md + retention-days: 1 - name: Save the PR number in an artifact if: github.event_name == 'pull_request' && (success() || failure()) @@ -64,4 +65,5 @@ jobs: if: github.event_name == 'pull_request' && (success() || failure()) with: name: pr-number - path: ./pr-number.txt \ No newline at end of file + path: ./pr-number.txt + retention-days: 1 \ No newline at end of file