fix: Added a new job to trigger Firebolt api workflow #496
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Pull Request | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: | |
- 'opened' | |
- 'synchronize' | |
push: | |
branches: | |
- next | |
env: | |
HUSKY: 0 | |
jobs: | |
release: | |
name: Trigger Workflows | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 'lts/*' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run validation and tests | |
run: npm pack | |
- name: Trigger Workflows | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.WORKFLOW_TRIGGER_SECRET }} # or use a custom token with proper permissions | |
repository: rdkcentral/firebolt-apis | |
event-type: trigger-workflow | |
client-payload: '{"OPENRPC_PR_BRANCH": "${{ github.event.pull_request.head.ref }}"}' | |
- name: Store the workflow run ID | |
run: | | |
echo "Waiting for Repo2 to finish execution" | |
wait-for-repo2: | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Poll Firebolt-api for JavaScript SDK generation | |
id: poll-javascript-sdk | |
run: | | |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}" | |
REPO_OWNER="rdkcentral" | |
REPO_NAME="firebolt-apis" | |
WORKFLOW_NAME="MFOS standalone sanity report - CORE,MANAGE,DISCOVERY" | |
while true; do | |
response=$(curl -s -H "Authorization: token $TOKEN" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows" | jq \ | |
--arg WORKFLOW_NAME "$WORKFLOW_NAME" \ | |
'.workflows[] | select(.name == $WORKFLOW_NAME)') | |
workflow_id=$(echo $response | jq -r '.id') | |
if [ "$workflow_id" == "null" ]; then | |
echo "Workflow not found, retrying in 10 seconds..." | |
sleep 10 | |
continue | |
fi | |
# Get the latest workflow run | |
run_response=$(curl -s -H "Authorization: token $TOKEN" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/$workflow_id/runs?per_page=1") | |
status=$(echo $run_response | jq -r '.workflow_runs[0].status') | |
conclusion=$(echo $run_response | jq -r '.workflow_runs[0].conclusion') | |
if [ "$status" == "completed" ] && [ "$conclusion" == "success" ]; then | |
echo "JavaScript SDK generated successfully." | |
break | |
elif [ "$status" == "completed" ] && [ "$conclusion" == "failure" ]; then | |
echo "Failed to generate JavaScript SDK." | |
exit 1 | |
else | |
echo "Still in progress. Checking again in 120 seconds..." | |
sleep 120 | |
fi | |
done | |
- name: Poll Firebolt-api for CPP SDK generation | |
id: poll-cpp-sdk | |
run: | | |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}" | |
REPO_OWNER="rdkcentral" | |
REPO_NAME="firebolt-apis" | |
WORKFLOW_NAME="CXX Build" | |
while true; do | |
response=$(curl -s -H "Authorization: token $TOKEN" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows" | jq \ | |
--arg WORKFLOW_NAME "$WORKFLOW_NAME" \ | |
'.workflows[] | select(.name == $WORKFLOW_NAME)') | |
workflow_id=$(echo $response | jq -r '.id') | |
if [ "$workflow_id" == "null" ]; then | |
echo "Workflow not found, retrying in 10 seconds..." | |
sleep 10 | |
continue | |
fi | |
# Get the latest workflow run | |
run_response=$(curl -s -H "Authorization: token $TOKEN" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/$workflow_id/runs?per_page=1") | |
status=$(echo $run_response | jq -r '.workflow_runs[0].status') | |
conclusion=$(echo $run_response | jq -r '.workflow_runs[0].conclusion') | |
if [ "$status" == "completed" ] && [ "$conclusion" == "success" ]; then | |
echo "CPP SDK generated successfully." | |
break | |
elif [ "$status" == "completed" ] && [ "$conclusion" == "failure" ]; then | |
echo "Failed to generate CPP SDK." | |
exit 1 | |
else | |
echo "Still in progress. Checking again in 120 seconds..." | |
sleep 120 | |
fi | |
done |