Skip to content

Commit 6384038

Browse files
authored
Working through code coverage from forks (#125)
* Working through build issues for new contributors * Adding retention period to artifacts
1 parent 3aa4379 commit 6384038

2 files changed

Lines changed: 60 additions & 4 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Comment on the Pull Request
2+
3+
# read-write repo token
4+
# See: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
5+
on:
6+
workflow_run:
7+
workflows: [".NET Core"]
8+
types:
9+
- completed
10+
11+
jobs:
12+
comment:
13+
runs-on: ubuntu-latest
14+
15+
# Only comment on the PR if this is a PR event
16+
if: github.event.workflow_run.event == 'pull_request'
17+
18+
steps:
19+
- name: Get the PR Number artifact
20+
uses: dawidd6/action-download-artifact@v2
21+
with:
22+
workflow: ${{ github.event.workflow_run.workflow_id }}
23+
workflow_conclusion: ""
24+
name: pr-number
25+
- name: Read PR Number into GitHub environment variables
26+
run: echo "PR_NUMBER=$(cat pr-number.txt)" >> $GITHUB_ENV
27+
- name: Confirm the PR Number (Debugging)
28+
run: echo $PR_NUMBER
29+
- name: Get the code coverage results file
30+
uses: dawidd6/action-download-artifact@v2
31+
with:
32+
workflow: ${{ github.event.workflow_run.workflow_id }}
33+
workflow_conclusion: ""
34+
name: code-coverage-results
35+
- name: Add Coverage PR Comment
36+
uses: marocchino/sticky-pull-request-comment@v2
37+
with:
38+
number: ${{ env.PR_NUMBER }}
39+
recreate: true
40+
path: code-coverage-results.md

.github/workflows/dotnetcore.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,25 @@ jobs:
4545
format: 'markdown'
4646
output: 'both'
4747

48-
- name: Add Coverage PR Comment
49-
uses: marocchino/sticky-pull-request-comment@v2
50-
if: github.event_name == 'pull_request'
48+
- name: Upload code coverage results artifact
49+
uses: actions/upload-artifact@v3
50+
if: success() || failure()
5151
with:
52-
recreate: true
52+
name: code-coverage-results
5353
path: code-coverage-results.md
54+
retention-days: 1
55+
56+
- name: Save the PR number in an artifact
57+
if: github.event_name == 'pull_request' && (success() || failure())
58+
shell: bash
59+
env:
60+
PR_NUMBER: ${{ github.event.number }}
61+
run: echo $PR_NUMBER > pr-number.txt
62+
63+
- name: Upload the PR number
64+
uses: actions/upload-artifact@v3
65+
if: github.event_name == 'pull_request' && (success() || failure())
66+
with:
67+
name: pr-number
68+
path: ./pr-number.txt
69+
retention-days: 1

0 commit comments

Comments
 (0)