-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 45e290e
Showing
3 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## PR 작성 전 체크 리스트 | ||
|
||
- merge 브랜치 확인할 것. **main으로 보내면 안 됨 :x:** | ||
- PR 작성 후 충돌이 안 나는지 확인할 것 | ||
- PR 제목: `[본인실명] step-n 미션 제목` (예: `[정호영] step-1 회원가입`) | ||
|
||
## PR 내용 | ||
|
||
- 구현한 내용의 핵심을 간단히 요약 기술할 것 | ||
- 가장 고민했던 내용을 짧게 설명 | ||
- 데모나 설계내용 포함도 OK | ||
|
||
**PR 보낼때 절취선과 위 내용 모두 삭제하고 보내세요.** | ||
|
||
---- 절취선 ---- | ||
|
||
## 구현 내용 | ||
|
||
## 고민 사항 | ||
|
||
## 기타 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: "PR merge on time v3.1 by honux" | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0-3 * * *" | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
issues: write | ||
|
||
jobs: | ||
merge: | ||
name: "Auto Merge on time" | ||
runs-on: "ubuntu-latest" | ||
|
||
steps: | ||
- name: "Merge pull request" | ||
uses: "actions/github-script@v6" | ||
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 | ||
} | ||
mergeable | ||
labels(first: 10) { | ||
nodes { | ||
name | ||
} | ||
} | ||
reviews(last: 1) { | ||
nodes { | ||
state | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
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" || !node.labels.nodes.length) { | ||
//add comment | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: node.number, | ||
body: "main 브랜치 병합 또는 적절한 라벨이 있는지 확인해 주세요." | ||
}) | ||
continue; | ||
} | ||
if (node.reviews.nodes.length && node.reviews.nodes[0].state === "CHANGES_REQUESTED") { | ||
//add comment | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: node.number, | ||
body: "변경 요청 중인 브랜치의 머지를 연기합니다." | ||
}) | ||
continue; | ||
} | ||
try { | ||
if(node.mergeable === "CONFLICTING") { | ||
// add comment | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: node.number, | ||
body: "충돌로 인해 자동 병합이 불가능합니다." | ||
}) | ||
// close pull request | ||
await github.rest.pulls.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: node.number, | ||
state: "closed" | ||
}) | ||
} else { | ||
//add comment | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: node.number, | ||
body: "자동 병합 완료" | ||
}) | ||
// merge pull request | ||
await github.rest.pulls.merge({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: node.number, | ||
merge_method: "merge" | ||
}) | ||
} | ||
} catch (e) { | ||
console.log("error", e); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
JSP Cafe |