초보자를 위한 GitHub 워크플로: 풀 요청에 레이블 및 주석 추가
오늘 저는 다음을 수행하는 간단한 GitHub 워크플로를 만드는 방법을 배웠습니다.
처음에는 이것이 복잡하고 여러 파일을 생성해야 하는 것처럼 보였습니다. actions/github-script:
This action makes it easy to quickly write a script in your workflow that uses the GitHub API and the workflow run context.
README는 주석을 추가하는 방법을 포함하여 몇 가지 실용적인 예를 나열합니다. 하지만 pull request 설명을 확인하는 방법이 누락되었습니다.
탐색 중인 것을 사용하는 다른 방법을 찾는 편리한 트릭은 "핵심 문구"를 선택하고 GitHub에서 검색하는 것입니다.
github.issues.createComment를 검색하면 this example by GeorgianaElena 내가 하고 싶은 일에 꽤 가깝습니다!다음은 단축되고 보다 일반적인 버전입니다.
name: Pull Request Messenger
on:
pull_request_target:
types: [opened]
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
# Create comment body as Markdown
var msg = `👋 Thanks for participating! I will review as soon as possible, usually within a few hours.
**Watch for notifications** as I may request some small changes to make sure this meets the guidelines.`
# Get pull request description
var body = context.payload.pull_request.body
# If `body` exists, check for conditions
# related to being from a contributor
if(body) {
var isContribution = body.contains('New Submission')
var incompleteGuidelines = body.contains('[]')
}
if(isContribution) {
# Create comment
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: msg
})
# Add 'new submission' label
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['new submission']
})
# If missed checking guidelines,
# add 'invalid' label
if(incompleteGuidelines) {
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['invalid']
})
}
}
Updated when I learned that setting it just "on"
pull_requestdidn't work for forks by non-contributors. Updating this topull_request_targetallows the workflow to run on forks. Read more about it in the docs which specifically mentions this change is needed for adding comments or labels.
이것은
.github/workflows/chose-a-name.yml 아래의 프로젝트에 배치되어야 합니다.더 매끄러운 테스트 방법이 있을 거라고 확신하지만, 작동하는지 확인하기 위해 조건을 충족하는 후속 PR을 수행했을 뿐입니다.
따라서 - Style Stage에 기여하게 되면 이 새로운 워크플로 봇이 여러분을 맞이합니다 😊
PS - if you are interested in creating a community-driven site, you may enjoy my recent series on CSS-Tricks: Building a Community Driven Site with Eleventy.
Reference
이 문제에 관하여(초보자를 위한 GitHub 워크플로: 풀 요청에 레이블 및 주석 추가), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/5t3ph/github-workflows-for-newbies-add-labels-and-comments-to-pull-requests-37da텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)