Last active
March 12, 2021 03:19
-
-
Save crongro/c58db9aec21b30a4060666408ac61a04 to your computer and use it in GitHub Desktop.
PR Merge on time
This file contains hidden or 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: "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" | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
main branch는 머지에서 제외