feat: add useQueryString | Image Automation #123
Workflow file for this run
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
name: Enforce PR Title Format with Comments | |
on: | |
pull_request: | |
types: [opened, edited, synchronize] | |
jobs: | |
validate-title: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check PR Title and Manage Comments | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const prTitle = context.payload.pull_request.title; | |
const prNumber = context.payload.pull_request.number; | |
const repoOwner = context.repo.owner; | |
const repoName = context.repo.repo; | |
const validTitleRegex = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9-_]+\))?:\s.+$/; | |
const commentIdentifier = "**๐ PR ์ ๋ชฉ ํ์ธ ๋ด**"; | |
const { data: comments } = await github.rest.issues.listComments({ | |
owner: repoOwner, | |
repo: repoName, | |
issue_number: prNumber, | |
}); | |
const botComment = comments.find(comment => comment.body.includes(commentIdentifier)); | |
if (!validTitleRegex.test(prTitle)) { | |
console.log("โ Invalid PR title detected."); | |
const invalidMessage = commentIdentifier + "\n\n" + | |
"โ PR ์ ๋ชฉ์ด ์๋ชป๋์์ต๋๋ค. ์ปจ๋ฒค์ ๋ ์ปค๋ฐ ํ์์ ๋ง์ถฐ์ฃผ์ธ์.\n\n" + | |
"์:\n" + | |
"- feat: ์๋ก์ด ๋ก๊ทธ์ธ ๊ธฐ๋ฅ ์ถ๊ฐ\n" + | |
"- fix: ์๋ชป๋ API ํธ์ถ ์์ \n" + | |
"- feat(react-native): React Native ๊ด๋ จ ๊ธฐ๋ฅ ์ถ๊ฐ\n\n" + | |
"๐ ์ฐธ๊ณ : [์ปจ๋ฒค์ ๋ ์ปค๋ฐ ๊ฐ์ด๋](https://www.conventionalcommits.org)"; | |
if (botComment) { | |
console.log("๐ Updating existing bot comment."); | |
await github.rest.issues.updateComment({ | |
owner: repoOwner, | |
repo: repoName, | |
comment_id: botComment.id, | |
body: invalidMessage, | |
}); | |
} else { | |
console.log("๐ Creating new bot comment."); | |
await github.rest.issues.createComment({ | |
owner: repoOwner, | |
repo: repoName, | |
issue_number: prNumber, | |
body: invalidMessage, | |
}); | |
} | |
throw new Error("Invalid PR title."); | |
} | |
console.log("โ PR title is valid."); | |
if (botComment) { | |
console.log("๐๏ธ Deleting bot comment."); | |
await github.rest.issues.deleteComment({ | |
owner: repoOwner, | |
repo: repoName, | |
comment_id: botComment.id, | |
}); | |
} |