Enable auto-merge for approved version bump pull requests. (#143282)
This commit is contained in:
parent
cbe36cd5c6
commit
833d0d69b9
|
@ -0,0 +1,61 @@
|
|||
name: Enable auto-merge for review
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- automerge
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
|
||||
jobs:
|
||||
automerge-review:
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
github.event.workflow_run.event == 'pull_request_review' &&
|
||||
github.event.workflow_run.conclusion == 'success'
|
||||
steps:
|
||||
- name: Download `event.json` artifact
|
||||
id: download_event_json
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
||||
...context.repo,
|
||||
run_id: ${{ github.event.workflow_run.id }},
|
||||
})
|
||||
|
||||
const eventArtifacts = artifacts.data.artifacts.filter((artifact) => {
|
||||
return artifact.name == "event.json"
|
||||
})
|
||||
|
||||
const download = await github.rest.actions.downloadArtifact({
|
||||
...context.repo,
|
||||
artifact_id: eventArtifacts[0].id,
|
||||
archive_format: 'zip',
|
||||
})
|
||||
|
||||
const fs = require('fs')
|
||||
fs.writeFileSync('${{ github.workspace }}/artifact.zip', Buffer.from(download.data))
|
||||
- name: Extract `event.json` and determine pull request and review info
|
||||
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@798e70c97009500150087d30d9f11c5444830385
|
||||
with:
|
||||
workflow: automerge
|
||||
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
|
|
@ -3,6 +3,9 @@ name: Enable auto-merge
|
|||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
pull_request_review:
|
||||
types:
|
||||
- submitted
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
|
@ -12,6 +15,14 @@ on:
|
|||
- labeled
|
||||
- unlabeled
|
||||
- ready_for_review
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pull-request:
|
||||
description: Pull Request Number
|
||||
required: false
|
||||
review:
|
||||
description: Review ID
|
||||
required: false
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${ github.head_ref || github.ref }}
|
||||
|
@ -23,12 +34,25 @@ jobs:
|
|||
if: startsWith(github.repository, 'Homebrew/')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: reitermarkus/automerge@e0cf02bcf5cbb9f9e9b359cc0ad3d9319bd5f427
|
||||
- name: Enable auto-merge
|
||||
uses: reitermarkus/automerge@e0cf02bcf5cbb9f9e9b359cc0ad3d9319bd5f427
|
||||
with:
|
||||
token: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
|
||||
token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }}
|
||||
merge-method: squash
|
||||
squash-commit-title: ${pull_request.title} (#${pull_request.number})
|
||||
squash-commit-message: '\n'
|
||||
do-not-merge-labels: automerge-skip,do not merge
|
||||
required-labels: bump-cask-pr
|
||||
pull-request: ${{ github.event.inputs.pull-request }}
|
||||
pull-request-author-associations: MEMBER,OWNER
|
||||
review: ${{ github.event.inputs.review }}
|
||||
review-author-associations: MEMBER,OWNER
|
||||
dry-run: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
if: github.event_name != 'pull_request_review'
|
||||
- name: Upload `event.json`
|
||||
uses: actions/upload-artifact@v3
|
||||
if: github.event_name == 'pull_request_review'
|
||||
with:
|
||||
name: event.json
|
||||
path: ${{ github.event_path }}
|
||||
if-no-files-found: error
|
||||
|
|
Loading…
Reference in New Issue