more robust workflow id

This commit is contained in:
Xi Yan 2025-01-10 16:55:30 -08:00
parent 285d8e12f2
commit 99c735228f

View file

@ -1,14 +1,15 @@
name: Publish Python 🐍 distribution 📦 to TestPyPI name: Publish Python 🐍 distribution 📦 to TestPyPI
on: on:
workflow_dispatch: # Keep manual trigger push
inputs: # workflow_dispatch: # Keep manual trigger
version: # inputs:
description: 'Version number (e.g. 0.0.63.dev20250111)' # version:
required: true # description: 'Version number (e.g. 0.0.63.dev20250111)'
type: string # required: true
schedule: # type: string
- cron: "0 0 * * *" # Run every day at midnight # schedule:
# - cron: "0 0 * * *" # Run every day at midnight
jobs: jobs:
trigger-client-and-models-build: trigger-client-and-models-build:
@ -53,11 +54,28 @@ jobs:
fi fi
# Get the run ID of the triggered workflow # Get the run ID of the triggered workflow
sleep 5 # Wait for workflow to be created max_attempts=60 # Try for up to 1 minute
run_id=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ attempt=1
"https://api.github.com/repos/meta-llama/llama-stack-client-python/actions/runs?event=repository_dispatch" \ while true; do
| jq '.workflow_runs[0].id') sleep 1
echo "workflow_id=$run_id" >> $GITHUB_OUTPUT run_id=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
"https://api.github.com/repos/meta-llama/llama-stack-client-python/actions/runs?event=repository_dispatch" \
| jq '.workflow_runs[0].id')
if [ "$run_id" != "null" ] && [ -n "$run_id" ]; then
echo "Found workflow ID: $run_id"
echo "workflow_id=$run_id" >> $GITHUB_OUTPUT
break
fi
if [ $attempt -ge $max_attempts ]; then
echo "Failed to get workflow ID after $max_attempts attempts"
exit 1
fi
echo "Attempt $attempt: Workflow ID not found yet, retrying..."
attempt=$((attempt + 1))
done
- name: Trigger llama-models workflow - name: Trigger llama-models workflow
id: trigger-models id: trigger-models
@ -75,11 +93,28 @@ jobs:
fi fi
# Get the run ID of the triggered workflow # Get the run ID of the triggered workflow
sleep 5 # Wait for workflow to be created max_attempts=60 # Try for up to 1 minute
run_id=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ attempt=1
"https://api.github.com/repos/meta-llama/llama-models/actions/runs?event=repository_dispatch" \ while true; do
| jq '.workflow_runs[0].id') sleep 1
echo "workflow_id=$run_id" >> $GITHUB_OUTPUT run_id=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
"https://api.github.com/repos/meta-llama/llama-models/actions/runs?event=repository_dispatch" \
| jq '.workflow_runs[0].id')
if [ "$run_id" != "null" ] && [ -n "$run_id" ]; then
echo "Found workflow ID: $run_id"
echo "workflow_id=$run_id" >> $GITHUB_OUTPUT
break
fi
if [ $attempt -ge $max_attempts ]; then
echo "Failed to get workflow ID after $max_attempts attempts"
exit 1
fi
echo "Attempt $attempt: Workflow ID not found yet, retrying..."
attempt=$((attempt + 1))
done
wait-for-workflows: wait-for-workflows:
name: Wait for triggered workflows name: Wait for triggered workflows