-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
76 lines (64 loc) · 2.41 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Checkout WP Deps Branch
description: Checkout a branch for the WP Deps update action
inputs:
github-token:
description: 'GitHub Token'
required: true
job-name:
description: 'The name of the job to mark'
required: true
outputs:
pr-head-sha:
description: 'The SHA of the head of the PR'
value: ${{ steps.parse-pr-number.outputs.PR_HEAD_SHA }}
# Based on example https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#using-data-from-the-triggering-workflow
runs:
using: composite
steps:
- name: 'Download artifact'
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
if ( allArtifacts.data.total_count == 0 || allArtifacts.data.artifacts.length == 0 ) {
throw new Error('No artifacts found');
}
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr_number"
})[0];
if ( !matchArtifact ) {
throw new Error('No matching artifact found');
}
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
require('fs').writeFileSync('pr_number.zip', Buffer.from(download.data));
- name: Parse PR Number
shell: bash
id: parse-pr-number
env:
GH_TOKEN: ${{ github.token }}
run: |
unzip pr_number.zip
cat pr_number
echo "PR_HEAD_SHA=$(gh api repos/${{ github.repository }}/pulls/$(cat pr_number) | jq -r '.head.sha')" >> $GITHUB_OUTPUT
rm pr_number.zip pr_number
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.parse-pr-number.outputs.PR_HEAD_SHA }}
- name: Mark Check Pending
if: github.event_name == 'workflow_run'
uses: boxuk/mark-check-status@main
with:
status: "pending"
pr-head-sha: ${{ steps.parse-pr-number.outputs.PR_HEAD_SHA }}
github-token: ${{ inputs.github-token }}
job-name: ${{ inputs.job-name }}