fix: Added a new job to trigger Firebolt api workflow #490
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: Run npm pack | |
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 | |
trigger-mfos: | |
name: Trigger and Poll MFOS Workflow | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Trigger MFOS Workflow | |
id: trigger-mfos | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.WORKFLOW_TRIGGER_SECRET }} | |
repository: rdkcentral/firebolt-apis | |
event-type: trigger-workflow | |
client-payload: '{"OPENRPC_PR_BRANCH": "${{ github.event.pull_request.head.ref }}"}' | |
- name: Fetch MFOS Workflow ID | |
id: fetch-mfos-id | |
run: | | |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}" | |
REPO_OWNER="rdkcentral" | |
REPO_NAME="firebolt-apis" | |
WORKFLOW_NAME="MFOS Workflow" # Adjust to the actual workflow name | |
# Fetch the most recent workflow run for the MFOS build | |
workflow_runs=$(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)') | |
mfos_workflow_id=$(echo "$workflow_runs" | jq -r '.id') | |
echo "MFOS Workflow ID: $mfos_workflow_id" | |
echo "::set-output name=mfos_workflow_id::$mfos_workflow_id" | |
- name: Poll MFOS Workflow Status | |
id: poll-mfos | |
run: | | |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}" | |
REPO_OWNER="rdkcentral" | |
REPO_NAME="firebolt-apis" | |
MFOS_WORKFLOW_ID="${{ steps.fetch-mfos-id.outputs.mfos_workflow_id }}" | |
# Poll MFOS Workflow | |
conclusion="in_progress" | |
while [ "$conclusion" == "in_progress" ]; do | |
run_response=$(curl -s -H "Authorization: token $TOKEN" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$MFOS_WORKFLOW_ID") | |
conclusion=$(echo $run_response | jq -r '.conclusion') | |
if [ "$conclusion" == "failure" ]; then | |
echo "Failing job: MFOS standalone sanity report - CORE,MANAGE,DISCOVERY workflow failed." | |
exit 1 | |
elif [ "$conclusion" != "in_progress" ]; then | |
echo "MFOS workflow completed successfully." | |
else | |
echo "MFOS workflow still in progress. Waiting..." | |
sleep 120 | |
fi | |
done | |
trigger-cxx: | |
name: Trigger and Poll CXX Build | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Trigger CXX Build | |
id: trigger-cxx | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.WORKFLOW_TRIGGER_SECRET }} | |
repository: rdkcentral/firebolt-apis | |
event-type: trigger-workflow | |
client-payload: '{"OPENRPC_PR_BRANCH": "${{ github.event.pull_request.head.ref }}"}' | |
- name: Fetch CXX Build Workflow ID | |
id: fetch-cxx-id | |
run: | | |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}" | |
REPO_OWNER="rdkcentral" | |
REPO_NAME="firebolt-apis" | |
WORKFLOW_NAME="CXX Build Workflow" # Adjust to the actual workflow name | |
# Fetch the most recent workflow run for the CXX build | |
workflow_runs=$(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)') | |
cxx_workflow_id=$(echo "$workflow_runs" | jq -r '.id') | |
echo "CXX Workflow ID: $cxx_workflow_id" | |
echo "::set-output name=cxx_workflow_id::$cxx_workflow_id" | |
- name: Poll CXX Build Workflow Status | |
id: poll-cxx | |
run: | | |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}" | |
REPO_OWNER="rdkcentral" | |
REPO_NAME="firebolt-apis" | |
CXX_WORKFLOW_ID="${{ steps.fetch-cxx-id.outputs.cxx_workflow_id }}" | |
# Poll CXX Build | |
conclusion="in_progress" | |
while [ "$conclusion" == "in_progress" ]; do | |
run_response=$(curl -s -H "Authorization: token $TOKEN" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$CXX_WORKFLOW_ID") | |
conclusion=$(echo $run_response | jq -r '.conclusion') | |
if [ "$conclusion" == "failure" ]; then | |
echo "::warning::CXX Build failed, but continuing the workflow." | |
break | |
elif [ "$conclusion" != "in_progress" ]; then | |
echo "CXX Build completed successfully." | |
else | |
echo "CXX Build still in progress. Waiting..." | |
sleep 120 | |
fi | |
done | |