GitHub 작업: GitHub 검사 외에 GitHub 상태를 푸시하는 방법
하지만 그 과정에서 몇 가지 단점을 발견했습니다. 한 가지 단점은 GitHub 작업의 결과가 Check 이 아니라 Status 이라는 것입니다.
UI에는 동일하지만 API에는 없습니다. 아래 이미지에서 마지막 줄은 API의 상태이지만 위의 모든 줄은 API 수준에서 확인합니다.

그게 뭐가 잘못됐어? Doctolib에는 검사가 아닌 상태에 의존하는 많은 자동화가 있습니다. Github 작업에 대한 일부 프로젝트를 온보딩하기 위해 우리는 우아한 솔루션을 찾고 있었습니다.
첫 번째 아이디어는 여기에서 상태를 푸시하는 단계를 워크플로 끝에 추가하는 것입니다.
다음과 같은 것:
- name: Create status
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"state": "${{ github.event.workflow_run.conclusion }}",
"context": "unit test (kube)",
"target_url": "${{ github.event.workflow_run.html_url }}"
}' \
--fail
이 솔루션은 작동하지만 그린 빌드(성공적인 빌드)에만 해당됩니다. 빨간색 빌드(실패한 빌드)의 경우 failure condition 을 사용할 수 있습니다. 여러 작업이 포함된 워크플로가 있는 경우 모든 작업에 이 실패 조건을 적용해야 합니다. 이는 고통스러울 수 있으며 코드 중복을 추가합니다.
그래서 더 간단한 솔루션을 찾았습니다. CI 워크플로(성공 및 실패)에 대해listen 독립적인 GitHub 워크플로를 갖고 그에 따라 상태를 설정하는 것입니다.
name: Set test status
on:
workflow_run:
workflows: ["Run tests"]
types:
- completed
jobs:
set_status:
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- name: Create status
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"state": "${{ github.event.workflow_run.conclusion }}",
"context": "unit test (kube)",
"target_url": "${{ github.event.workflow_run.html_url }}"
}' \
--fail
자유롭게 재사용하세요. 다음과 같이 변경하기만 하면 됩니다.
on
절에 있는 CI 워크플로의 이름입니다. context
매개변수에서 GitHub에 푸시하려는 상태의 이름입니다. Reference
이 문제에 관하여(GitHub 작업: GitHub 검사 외에 GitHub 상태를 푸시하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/doctolib/github-actions-how-to-push-a-github-status-in-addition-of-github-checks-3d27텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)