Skip to content

Trigger and Monitor SQ Test #1

Trigger and Monitor SQ Test

Trigger and Monitor SQ Test #1

name: Trigger and Monitor SQ Test
on:
workflow_dispatch:
inputs:
SQA_branch:
description: 'SQA Branch name'
required: true
default: '2-add-bluetooth-aoa-project'
jobs:
trigger-SQ-test:
runs-on: ubuntu-latest
steps:
- name: Trigger Check-Time Workflow
id: trigger
run: |
echo "Repository: $REPOSITORY_NAME"
echo "Branch: $BRANCH_NAME"
echo "Owner: $OWNER_NAME"
response=$(curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
https://api.github.com/repos/SiliconLabsInternal/DevS-SQA/actions/workflows/01-sonarqube-analysis.yml/dispatches \
-d '{"ref":"${{inputs.SQA_branch}}","inputs":{"repository": "${{ github.repository }}" ,"ref":"${{ github.ref }}"}}')
echo "Triggered workflow: $response"
if echo "$response" | grep -q '"message": "Not Found"'; then
echo "Error: Workflow or repository not found. Please check the repository name, workflow file name, and branch name."
exit 1
fi
- name: Wait for Check-Time Workflow to Complete
id: wait
env:
TIMEOUT: 1800
run: |
sleep 30
run_id=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
https://api.github.com/repos/SiliconLabsInternal/DevS-SQA/actions/runs \
| jq '.workflow_runs[] | select(.name=="Bluetooth AoA Check") | .id' | head -n 1)
echo "Run ID: $run_id"
start_time=$(date +%s)
while true; do
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ $elapsed_time -ge $TIMEOUT ]; then
echo "Error: Workflow did not complete within $((TIMEOUT / 60)) minutes."
exit 1
fi
status=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
https://api.github.com/repos/SiliconLabsInternal/DevS-SQA/actions/runs/$run_id \
| jq -r '.status')
conclusion=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
https://api.github.com/repos/SiliconLabsInternal/DevS-SQA/actions/runs/$run_id \
| jq -r '.conclusion')
echo "Status: $status, Conclusion: $conclusion"
if [[ "$status" == "completed" ]]; then
if [[ "$conclusion" == "success" ]]; then
echo "Workflow completed successfully."
exit 0
else
echo "Workflow failed."
exit 1
fi
fi
sleep 30
done