-
Notifications
You must be signed in to change notification settings - Fork 59
90 lines (84 loc) · 3.99 KB
/
on-review-add-label.yml
File metadata and controls
90 lines (84 loc) · 3.99 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Run Label Action on PR Review Event
on:
workflow_run:
workflows: ["Dummy Workflow on review"]
types:
- completed
permissions:
pull-requests: write
contents: write
issues: write
jobs:
run_on_workflow_a_success:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Run this on Dummy workflow success
run: echo "Dummy Workflow on review completes successfully"
download_context_artifact:
needs:
- run_on_workflow_a_success
runs-on: ubuntu-latest
steps:
- name: 'Download artifact'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "context.json"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/context.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip context.zip
- name: 'Return Parsed JSON'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
id: return-parsed-json
with:
script: |
let fs = require('fs');
let data = fs.readFileSync('./context.json');
return JSON.parse(data);
outputs:
pr_num: ${{fromJSON(steps.return-parsed-json.outputs.result).pr_num}}
event_action: ${{fromJSON(steps.return-parsed-json.outputs.result).event_action}}
review_state: ${{fromJSON(steps.return-parsed-json.outputs.result).review_state}}
event_name: ${{fromJSON(steps.return-parsed-json.outputs.result).event_name}}
comment_body: ${{fromJSON(steps.return-parsed-json.outputs.result).comment_body}}
review_comment_body: ${{fromJSON(steps.return-parsed-json.outputs.result).review_comment_body}}
user_login: ${{fromJSON(steps.return-parsed-json.outputs.result).user_login}}
action: ${{fromJSON(steps.return-parsed-json.outputs.result).action}}
log_context_values:
needs:
- download_context_artifact
runs-on: ubuntu-latest
steps:
- name: 'Set all Env Variable'
run: |
echo "GITHUB_PR_NUMBER=${{ needs.download_context_artifact.outputs.pr_num }}" >> "$GITHUB_ENV"
echo "GITHUB_EVENT_ACTION=${{ needs.download_context_artifact.outputs.event_action }}" >> "$GITHUB_ENV"
echo "GITHUB_EVENT_REVIEW_STATE=${{ needs.download_context_artifact.outputs.review_state }}" >> "$GITHUB_ENV"
echo "GITHUB_EVENT_NAME=${{ needs.download_context_artifact.outputs.event_name }}" >> "$GITHUB_ENV"
echo "COMMENT_BODY=${{ needs.download_context_artifact.outputs.comment_body }}" >> "$GITHUB_ENV"
echo "REVIEW_COMMENT_BODY=${{ needs.download_context_artifact.outputs.review_comment_body }}" >> "$GITHUB_ENV"
echo "GITHUB_USER_LOGIN=${{ needs.download_context_artifact.outputs.user_login }}" >> "$GITHUB_ENV"
echo "ACTION=${{ needs.download_context_artifact.outputs.action }}" >> "$GITHUB_ENV"
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
- name: 'Run add-remove-labels action'
env:
GITHUB_TOKEN: ${{ secrets.RHODS_CI_BOT_PAT }}
GITHUB_EVENT_NAME: ${{ needs.download_context_artifact.outputs.event_name }}
run: uv run python .github/workflows/scripts/pr_workflow.py