-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: simplify to direct API calls for check run creation
Co-Authored-By: Aaron <AJ> Steers <[email protected]>
- Loading branch information
1 parent
c5bf0c8
commit 09ad54b
Showing
1 changed file
with
31 additions
and
40 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 |
---|---|---|
|
@@ -8,48 +8,39 @@ on: | |
- '.github/workflows/dummy_check_result.yml' | ||
|
||
jobs: | ||
main_job: | ||
name: "Main Job" | ||
test_check: | ||
name: "Test Check" | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
check_id: ${{ steps.create_check.outputs.check_id }} | ||
permissions: | ||
checks: write | ||
contents: read | ||
steps: | ||
- name: Create Initial Check Run | ||
id: create_check | ||
uses: LouisBrunner/[email protected] | ||
with: | ||
token: ${{ github.token }} | ||
name: "Test Results (Custom)" | ||
status: "in_progress" | ||
output: | | ||
{ | ||
"title": "Test Results", | ||
"summary": "Running tests..." | ||
} | ||
- name: Sleep for a moment | ||
run: sleep 5 | ||
|
||
update_check: | ||
needs: main_job | ||
name: "Update Check" | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
checks: write | ||
contents: read | ||
steps: | ||
- name: Update Check Run | ||
uses: LouisBrunner/[email protected] | ||
with: | ||
token: ${{ github.token }} | ||
check_id: ${{ needs.main_job.outputs.check_id }} | ||
status: "completed" | ||
conclusion: "failure" | ||
details_url: "https://www.google.com/search?q=test-failure" | ||
output: | | ||
{ | ||
"title": "Test Failed", | ||
"summary": "This is a test failure check with custom details URL." | ||
} | ||
- name: Create Check Run | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
HEAD_SHA="${{ github.event.pull_request.head.sha || github.sha }}" | ||
# Create check run with custom details URL | ||
response=$(gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
repos/${{ github.repository }}/check-runs \ | ||
-f name="Test Results (Direct API)" \ | ||
-f head_sha="$HEAD_SHA" \ | ||
-f status="completed" \ | ||
-f conclusion="failure" \ | ||
-f details_url="https://www.google.com/search?q=test-failure" \ | ||
-f output="{\"title\":\"Test Results\",\"summary\":\"This is a test check using direct API calls.\"}") | ||
# Get the check run ID | ||
check_id=$(echo "$response" | jq -r '.id') | ||
echo "Created check run ID: $check_id" | ||
# Verify the check run details | ||
echo "Verifying check run details..." | ||
gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
repos/${{ github.repository }}/check-runs/$check_id | jq '{name, details_url, html_url, status, conclusion}' |