automerge-run #13744
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@e2e5e9a103e331dad343f381a29e654aea3cf8fc | |
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 |