|
8 | 8 | workflow_run: |
9 | 9 | workflows: ["Merge Conditions"] |
10 | 10 | types: [completed] |
| 11 | + # Manual trigger for testing (remove after validation) |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + branch: |
| 15 | + description: "PR branch (e.g., auto-update/vllm-99.99.99)" |
| 16 | + required: true |
| 17 | + run_id: |
| 18 | + description: "Failed workflow run ID" |
| 19 | + required: true |
| 20 | + # PR trigger for testing (remove after validation) |
| 21 | + pull_request: |
| 22 | + branches: [main] |
| 23 | + paths: |
| 24 | + - "scripts/autocurrency/agent-fix.py" |
| 25 | + - ".github/workflows/agent-currency-fix.yml" |
11 | 26 |
|
12 | 27 | permissions: |
13 | 28 | contents: read |
|
23 | 38 | jobs: |
24 | 39 | fix-agent: |
25 | 40 | if: >- |
26 | | - github.event.workflow_run.conclusion == 'failure' && |
27 | | - startsWith(github.event.workflow_run.head_branch, 'auto-update/') |
| 41 | + github.event_name == 'workflow_dispatch' || |
| 42 | + github.event_name == 'pull_request' || ( |
| 43 | + github.event.workflow_run.conclusion == 'failure' && |
| 44 | + startsWith(github.event.workflow_run.head_branch, 'auto-update/') |
| 45 | + ) |
28 | 46 | runs-on: |
29 | 47 | - codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }} |
30 | 48 | fleet:default-runner |
31 | 49 | buildspec-override:true |
32 | 50 | env: |
33 | | - HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} |
34 | | - RUN_ID: ${{ github.event.workflow_run.id }} |
35 | | - RUN_URL: ${{ github.event.workflow_run.html_url }} |
| 51 | + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch || inputs.branch || github.head_ref }} |
| 52 | + RUN_ID: ${{ github.event.workflow_run.id || inputs.run_id || '' }} |
| 53 | + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
36 | 54 | steps: |
37 | 55 | - name: Validate branch name |
38 | 56 | run: | |
| 57 | + # Skip validation for pull_request testing |
| 58 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 59 | + echo "Skipping branch validation for PR testing" |
| 60 | + exit 0 |
| 61 | + fi |
39 | 62 | if [[ ! "$HEAD_BRANCH" =~ ^auto-update/[a-z]+-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
40 | 63 | echo "::error::Branch '${HEAD_BRANCH}' does not match expected pattern." |
41 | 64 | exit 1 |
|
57 | 80 | GH_TOKEN: ${{ github.token }} |
58 | 81 | run: | |
59 | 82 | TRACKED="PR - vLLM EC2|PR - vLLM SageMaker|PR - SGLang EC2|PR - SGLang SageMaker" |
60 | | - SHA=$(gh api "/repos/${{ github.repository }}/actions/runs/${RUN_ID}" --jq '.head_sha') |
| 83 | +
|
| 84 | + # Get HEAD SHA depending on event type |
| 85 | + if [ -n "$RUN_ID" ]; then |
| 86 | + SHA=$(gh api "/repos/${{ github.repository }}/actions/runs/${RUN_ID}" --jq '.head_sha') |
| 87 | + else |
| 88 | + SHA="${{ github.event.pull_request.head.sha || github.sha }}" |
| 89 | + fi |
| 90 | + echo "SHA: $SHA" |
61 | 91 |
|
62 | 92 | FAILED_RUN_IDS=$(gh api "/repos/${{ github.repository }}/actions/runs?head_sha=${SHA}&status=completed&per_page=50" \ |
63 | 93 | --jq "[.workflow_runs[] | select(.conclusion == \"failure\" and (.name | test(\"${TRACKED}\")))] | .[].id" \ |
@@ -93,16 +123,19 @@ jobs: |
93 | 123 | if: steps.failures.outputs.has_failures == 'true' |
94 | 124 | uses: actions/checkout@v5 |
95 | 125 | with: |
96 | | - ref: main |
| 126 | + ref: ${{ github.event_name == 'pull_request' && github.head_ref || 'main' }} |
97 | 127 | fetch-depth: 0 |
98 | 128 | token: ${{ steps.app-token.outputs.token }} |
99 | 129 |
|
100 | 130 | - name: Prepare workspace |
101 | 131 | if: steps.failures.outputs.has_failures == 'true' |
102 | 132 | run: | |
103 | 133 | cp scripts/autocurrency/agent-fix.py /tmp/agent-fix.py |
104 | | - git fetch origin "$HEAD_BRANCH" |
105 | | - git checkout "origin/$HEAD_BRANCH" -B pr-branch |
| 134 | + # For pull_request testing, we're already on the right branch |
| 135 | + if [ "${{ github.event_name }}" != "pull_request" ]; then |
| 136 | + git fetch origin "$HEAD_BRANCH" |
| 137 | + git checkout "origin/$HEAD_BRANCH" -B pr-branch |
| 138 | + fi |
106 | 139 |
|
107 | 140 | - name: Count previous attempts |
108 | 141 | if: steps.failures.outputs.has_failures == 'true' |
|
0 commit comments