-
Notifications
You must be signed in to change notification settings - Fork 2.2k
build: set up workflow to automatically manage/mirror the v0.16.1 branch #7577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Merge pull request into v0.16.1 | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: | ||
- master | ||
milestone: | ||
types: [created, edited] | ||
names: | ||
- 'v0.16.1' | ||
|
||
jobs: | ||
create-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to check out the code here and below? Since all we do is invoke some GitHub APIs. |
||
|
||
- name: Create pull request to merge into v0.16.1 | ||
uses: peter-evans/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: v0.16.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The branch is called |
||
commit-message: Merge pull request #${{ github.event.pull_request.number }} | ||
title: Merge pull request #${{ github.event.pull_request.number }} into v0.16.1 | ||
body: | | ||
This pull request was automatically created to merge pull request #${{ github.event.pull_request.number }} | ||
into the v0.16.1 branch because it was merged into the master branch and had the v0.16.1 milestone. | ||
base: v0.16.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, re branch name. |
||
draft: false | ||
|
||
merge-pr: | ||
needs: create-pr | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Merge pull request into v0.16.1 | ||
uses: actions/github-script@v5 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { context } = github; | ||
const prNumber = context.payload.pull_request.number; | ||
const headRef = context.payload.pull_request.head.ref; | ||
const baseRef = 'v0.16.1'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Branch name is wrong here too. Also, not sure what the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or we could just use the following additional step in the
See https://github.com/peter-evans/enable-pull-request-automerge#enable-pull-request-auto-merge. |
||
|
||
// Merge the pull request into the target branch | ||
await github.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/heads/${baseRef}`, | ||
sha: context.payload.pull_request.head.sha, | ||
}); | ||
|
||
const mergeResponse = await github.pulls.merge({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: prNumber, | ||
sha: headRef, | ||
merge_method: 'merge', | ||
}); | ||
|
||
console.log(`Merged PR ${prNumber} into ${baseRef}: ${mergeResponse.status}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need
if: github.event.pull_request.merged == true
here to make sure this isn't triggered when someone closes the PR without merging (see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges).