Skip to content

Instantly share code, notes, and snippets.

@crongro
Last active March 12, 2021 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crongro/c58db9aec21b30a4060666408ac61a04 to your computer and use it in GitHub Desktop.
Save crongro/c58db9aec21b30a4060666408ac61a04 to your computer and use it in GitHub Desktop.
PR Merge on time
name: "PR Merge on time v2"
on:
schedule:
- cron: '00 13,16 * * *'
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
merge:
name: "Auto Merge on time"
runs-on: "ubuntu-latest"
steps:
- name: "Merge pull request"
uses: "actions/github-script@v3"
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const query = `query($owner:String!, $name:String!) {
repository(owner: $owner, name: $name) {
pullRequests(last: 100, states: OPEN) {
edges {
node {
number
headRefName
baseRefName
author {
login
}
repository {
name
}
}
}
}
}
}`
const variables = {
owner: context.repo.owner,
name: context.repo.repo,
}
const {repository:{pullRequests:{edges: list}}} = await github.graphql(query, variables)
for( let {node} of list) {
if(node.baseRefName === "main") continue;
await github.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: node.number,
merge_method: "squash"
})
}
@crongro
Copy link
Author

crongro commented Mar 12, 2021

main branch는 머지에서 제외

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment