File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Test Main Workflow
2+ on :
3+ workflow_dispatch :
4+ inputs :
5+ should_fail :
6+ description : ' Should this workflow fail?'
7+ required : true
8+ default : ' false'
9+ type : choice
10+ options :
11+ - ' true'
12+ - ' false'
13+
14+ jobs :
15+ test :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - name : Test step
19+ run : |
20+ echo "Running for 30 seconds..."
21+ sleep 30
22+ if [ "${{ github.event.inputs.should_fail }}" = "true" ]; then
23+ echo "Failing as requested"
24+ exit 1
25+ else
26+ echo "Succeeding as requested"
27+ fi
Original file line number Diff line number Diff line change 1+ name : Test Release Workflow
2+ on :
3+ workflow_dispatch :
4+
5+ jobs :
6+ check-and-release :
7+ runs-on : ubuntu-latest
8+ steps :
9+ - name : Check main workflow status
10+ run : |
11+ WORKFLOW_ID=$(gh api repos/${{ github.repository }}/actions/workflows --jq '.workflows[] | select(.name=="Test Main Workflow") | .id')
12+ LATEST_RUN=$(gh api repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/runs --jq '.workflow_runs[] | select(.head_branch=="${{ github.ref_name }}") | {conclusion, status}' | head -1)
13+ STATUS=$(echo "$LATEST_RUN" | jq -r '.status')
14+ CONCLUSION=$(echo "$LATEST_RUN" | jq -r '.conclusion')
15+
16+ if [ "$STATUS" = "in_progress" ] || [ "$STATUS" = "queued" ]; then
17+ echo "Main workflow is still running (status: $STATUS). Cannot proceed with release."
18+ exit 1
19+ elif [ "$CONCLUSION" != "success" ]; then
20+ echo "Latest main workflow on branch ${{ github.ref_name }} conclusion: $CONCLUSION"
21+ exit 1
22+ fi
23+ echo "Main workflow succeeded, proceeding with release"
24+ env :
25+ GH_TOKEN : ${{ github.token }}
26+
27+ - name : Mock release step
28+ run : echo "Release would happen here"
You can’t perform that action at this time.
0 commit comments