generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 14
65 lines (62 loc) · 2.37 KB
/
automerge-run.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
name: automerge-run
on:
workflow_run:
workflows:
- automerge
types:
- completed
jobs:
automerge-run:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request_review' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Event
run: |
echo "${EVENT_NAME}"
echo "${EVENT_JSON}"
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_JSON: ${{ toJSON(github.event) }}
- name: Download `event.json`
id: download_event_json
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
...context.repo,
run_id: ${{ github.event.workflow_run.id }},
})
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "event.json"
})[0]
const download = await github.rest.actions.downloadArtifact({
...context.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs')
fs.writeFileSync('${{ github.workspace }}/artifact.zip', Buffer.from(download.data))
if: >
github.event.workflow_run.event == 'pull_request_review' &&
github.event.workflow_run.conclusion == 'success'
- name: Extract `event.json`
id: review_info
run: |
unzip artifact.zip
echo "pull_request=$(jq -r .pull_request.number event.json)" >> "${GITHUB_OUTPUT}"
echo "review=$(jq -r .review.id event.json)" >> "${GITHUB_OUTPUT}"
if: steps.download_event_json.outcome == 'success'
- name: Trigger workflow for review ${{ steps.review_info.outputs.review }} on pull request \#${{ steps.review_info.outputs.pull_request }}
uses: benc-uk/workflow-dispatch@25b02cc069be46d637e8fe2f1e8484008e9e9609
with:
workflow: automerge.yml
inputs: >
{
"pull-request": "${{ steps.review_info.outputs.pull_request }}",
"review": "${{ steps.review_info.outputs.review }}"
}
if: >
steps.review_info.outputs.pull_request &&
steps.review_info.outputs.review