@@ -15,7 +15,51 @@ concurrency:
15
15
cancel-in-progress : true
16
16
17
17
jobs :
18
+ test-pr-nr :
19
+ if : github.ref == 'refs/heads/main'
20
+ runs-on : " ubuntu-latest"
21
+ steps :
22
+ # Checkout code in order to determine PR number
23
+
24
+ with :
25
+ fetch-depth : 0
26
+
27
+ # https://stackoverflow.com/a/70102700
28
+ - name : Get Pull Request Number
29
+ id : pr
30
+ run : echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")"
31
+ env :
32
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
33
+
34
+ - name : Get PR number
35
+ id : pr2
36
+ run : |
37
+ commit_sha=$(git rev-parse HEAD)
38
+ pr_number=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
39
+ "https://api.github.com/repos/jorisroovers/gitlint/commits/$commit_sha/pulls" | jq -r '.[0].number')
40
+ echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
41
+ env :
42
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
43
+
44
+ - run : echo ${{ env.PR_NUMBER }}
45
+
46
+ - run : jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH"
47
+
48
+ - run : echo "${{ github.event.pull_request.number }}"
49
+
50
+ - run : |
51
+ echo "PR number: ${{ steps.pr.outputs.pull_request_number }}"
52
+
53
+ - run : gh pr view --json number -q .number
54
+ env :
55
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
56
+
57
+ - run : gh pr view --json
58
+ env :
59
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60
+
18
61
tests :
62
+ needs : test-pr-nr
19
63
runs-on : " ubuntu-latest"
20
64
strategy :
21
65
matrix :
@@ -246,6 +290,18 @@ jobs:
246
290
if : github.ref == 'refs/heads/main'
247
291
runs-on : " ubuntu-latest"
248
292
steps :
293
+ # Checkout code in order to determine PR number
294
+
295
+ with :
296
+ fetch-depth : 0
297
+
298
+ # https://stackoverflow.com/a/70102700
299
+ - name : Get Pull Request Number
300
+ id : pr
301
+ run : echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")"
302
+ env :
303
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
304
+
249
305
- uses : actions/github-script@v6
250
306
with :
251
307
script : |
@@ -259,7 +315,7 @@ jobs:
259
315
\`\`\`
260
316
`;
261
317
github.rest.issues.createComment({
262
- issue_number: context.issue.number ,
318
+ issue_number: ${{ steps.pr.outputs.pull_request_number }} ,
263
319
owner: context.repo.owner,
264
320
repo: context.repo.repo,
265
321
body: body
0 commit comments