Skip to content

Commit 5c29f0b

Browse files
committed
test main and release workflows
1 parent 6653f5a commit 5c29f0b

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.github/workflows/test-main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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

.github/workflows/test-release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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"

0 commit comments

Comments
 (0)