Skip to content

Add unified status check #14

Add unified status check

Add unified status check #14

Workflow file for this run

name: Merge group tests
on:
merge_group:
pull_request:
jobs:
test-ref:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
steps:
- uses: actions/checkout@v4
- name: Print branch names
run: |
echo "Head ref: ${{ github.event.merge_group.head_ref }}"
echo "Base ref: ${{ github.event.merge_group.base_ref }}"
- uses: actions/checkout@v4
with:
ref: ${{ github.event.merge_group.base_ref }}
test-ref-b:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Print branch name
run: |
echo "Base ref: ${{ github.base_ref }}"
exit 1
# Wait and verify job
wait-and-verify:
if: always()
needs: [test-ref, test-ref-b]
runs-on: ubuntu-latest
steps:
- name: Check job statuses
env:
TEST_REF_STATUS: ${{ needs.test-ref.result }}
TEST_REF_B_STATUS: ${{ needs.test-ref-b.result }}
run: |
# Create an associative array of job statuses
declare -A job_results=(
["test-ref"]="${{ needs.test-ref.result }}"
["test-ref-b"]="${{ needs.test-ref-b.result }}"
)
# Iterate through jobs and get their results
failed_count=0
for job in "${!job_results[@]}"; do
RESULT=${job_results[$job]}
if [[ "$RESULT" == "failure" ]]; then
((failed_count++))
fi
echo "$job result: $RESULT"
done
if [ "$failed_count" -gt 0 ]; then
echo "Some jobs failed, exiting..."
exit 1
else
echo "All jobs succeeded or were skipped"
exit 0
fi