Skip to content

Commit 7e79092

Browse files
authored
Add main build validation for release workflow (aws-observability#443)
*Issue #, if available:* *Description of changes:* This PR modifies the release build workflow to wait for the main build workflow in the same branch to complete successfully. before proceeding with the release. If the latest main build run has status `queued` or `in_progress`, or has completed without the conclusion `success`, the workflow exits early. Tested this logic in personal fork with dummy workflows. failed release workflow example 1 (main build in progress): https://github.com/ezhang6811/aws-otel-python-instrumentation/actions/runs/17478717524/job/49644636222 failed release workflow example 2 (main build failed): https://github.com/ezhang6811/aws-otel-python-instrumentation/actions/runs/17478713160/job/49644619601 successful release workflow example: https://github.com/ezhang6811/aws-otel-python-instrumentation/actions/runs/17478731487 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
2 parents f5770d9 + a134b88 commit 7e79092

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

.github/workflows/release-build.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ jobs:
2828
- name: Checkout Repo @ SHA - ${{ github.sha }}
2929
uses: actions/checkout@v4
3030

31+
- name: Check main build status
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: |
35+
WORKFLOW_ID=$(gh api repos/${{ github.repository }}/actions/workflows --jq '.workflows[] | select(.name=="Python Instrumentation Main Build") | .id')
36+
LATEST_RUN=$(gh api repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/runs --jq '[.workflow_runs[] | select(.head_branch=="${{ github.ref_name }}")] | sort_by(.created_at) | .[-1] | {conclusion, status}')
37+
STATUS=$(echo "$LATEST_RUN" | jq -r '.status')
38+
CONCLUSION=$(echo "$LATEST_RUN" | jq -r '.conclusion')
39+
40+
if [ "$STATUS" = "in_progress" ] || [ "$STATUS" = "queued" ]; then
41+
echo "Main build is still running (status: $STATUS). Cannot proceed with release."
42+
exit 1
43+
elif [ "$CONCLUSION" != "success" ]; then
44+
echo "Latest main build on branch ${{ github.ref_name }} conclusion: $CONCLUSION"
45+
exit 1
46+
fi
47+
echo "Main build succeeded, proceeding with release"
48+
3149
- name: Build Wheel and Image Files
3250
uses: ./.github/actions/artifacts_build
3351
with:

0 commit comments

Comments
 (0)