[Internal] Use statuses instead of checks #44
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: Integration Tests | |
on: | |
pull_request: | |
branches: [ main ] | |
jobs: | |
check: | |
name: Run Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: List checks | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ressha=$(gh run list --commit ${{github.sha}}) | |
echo $ressha | |
respr=$(gh pr checks ${{github.event.pull_request.number}}) | |
echo $respr | |
- name: Create Check | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
check_run_id=$(gh api -X POST -H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-f name='Integration Tests Check' \ | |
-f head_sha=${{ github.sha }} \ | |
-f status='queued' \ | |
-f output[title]="Integration Tests Check" \ | |
-f output[summary]="This check is being created." \ | |
--jq '.id' \ | |
/repos/${{ github.repository }}/check-runs) | |
# Adding instructions to the check details. | |
gh api -X PATCH -H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-f 'status=queued' \ | |
-f name='Integration Tests Check' \ | |
-f output[title]="Integration Tests Check" \ | |
-f output[summary]="Waiting for test to run." \ | |
-f output[text]="Run the corresponding workflow using the provided check_run_id: | |
Check Run ID: $check_run_id " \ | |
/repos/${{ github.repository }}/check-runs/$check_run_id | |
echo "CHECK_RUN_ID=$check_run_id" >> $GITHUB_ENV | |
- name: Write PR Comment | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Delete previous comment if it exists | |
previous_comment_id=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ | |
--jq '.[] | select(.body | startswith("<!-- INTEGRATION_TESTS -->")) | .id') | |
if [ ! -z "$previous_comment_id" ]; then | |
gh api repos/${{ github.repository }}/issues/comments/$previous_comment_id -X DELETE | |
fi | |
# Add new comment | |
gh pr comment ${{ github.event.pull_request.number }} --body \ | |
"<!-- INTEGRATION_TESTS --> | |
Run integration tests using the corresponding workflow: | |
Inputs: | |
pull_request_number=${{github.event.pull_request.number}} | |
check_run_id=${{ env.CHECK_RUN_ID }} | |
This check will be approved automatically on success. | |
Check URL: ${{ github.server_url }}/${{ github.repository }}/runs/${{ env.CHECK_RUN_ID }} | |
" |