Skip to content

Commit 203da74

Browse files
authored
Merge pull request #2985 from IntersectMBO/fix/commit-status-checkout
Fix: commit status checkout issue
2 parents 52cbbaf + 8b0d832 commit 203da74

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.github/scripts/set_commit_status.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Ensure required environment variables are set
4-
if [ -z "$GITHUB_REPOSITORY" ] || [ -z "$GITHUB_SHA" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_RUN_ID" ]; then
4+
if [ -z "$GITHUB_REPOSITORY" ] || [ -z "$COMMIT_SHA" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_RUN_ID" ]; then
55
echo "Missing required environment variables!"
66
exit 1
77
fi
@@ -69,7 +69,7 @@ fi
6969
# Send commit status update to GitHub
7070
curl -X POST -H "Authorization: Bearer ${GITHUB_TOKEN}" \
7171
-H "Accept: application/vnd.github+json" \
72-
https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA} \
72+
https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${COMMIT_SHA} \
7373
-d "{\"state\": \"${TEST_STATUS}\", \"context\": \"${CONTEXT}\", \"description\": \"${DESCRIPTION}\", \"target_url\": \"${TARGET_URL}\"}"
7474

7575
echo "Commit status updated successfully!"

.github/workflows/test_backend.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ jobs:
4646
steps:
4747
- name: Checkout code
4848
uses: actions/checkout@v4
49+
with:
50+
ref: ${{ env.COMMIT_SHA }}
4951

5052
- name: Set pending commit status
5153
id: set-pending-status
5254
run: |
5355
echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
5456
curl -X POST -H "Authorization: Bearer ${{ github.token }}" \
5557
-H "Accept: application/vnd.github+json" \
56-
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
58+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \
5759
-d "{\"state\": \"pending\", \"context\": \"Backend Tests : ${{env.BASE_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
5860
5961
@@ -184,3 +186,4 @@ env:
184186
BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }}
185187
REPORT_NAME: govtool-backend
186188
GH_PAGES: ${{vars.GH_PAGES}}
189+
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}

.github/workflows/test_integration_playwright.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ jobs:
4848
working-directory: tests/govtool-frontend/playwright
4949
steps:
5050
- uses: actions/checkout@v4
51+
with:
52+
ref: ${{ env.COMMIT_SHA }}
5153
- name: Set pending commit status
5254
id: set-pending-status
5355
run: |
5456
echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
5557
curl -X POST -H "Authorization: Bearer ${{ github.token }}" \
5658
-H "Accept: application/vnd.github+json" \
57-
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
59+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \
5860
-d "{\"state\": \"pending\", \"context\": \"Playwright Tests : ${{env.HOST_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
5961
6062
- uses: actions/setup-node@v4
@@ -223,3 +225,4 @@ env:
223225
HOST_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}
224226
REPORT_NAME: govtool-frontend
225227
GH_PAGES: ${{vars.GH_PAGES}}
228+
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}

0 commit comments

Comments
 (0)