Skip to content

Commit e832401

Browse files
feat(ci): dynamic stack naming and workflow_dispatch deploy trigger
build.yml: Replace hardcoded stackName with trigger-aware naming: - push to main: main-<compute_type> - pull_request: pr<number>-<compute_type> - merge_group: mg<pr_number>-<compute_type> - workflow_dispatch: <branch>-<compute_type> - fallback: <compute_type>-<sha7> All inputs sanitized (alphanumeric + hyphens, 60-char branch cap). deploy.yml: Add workflow_dispatch trigger with compute_type choice input (all, agentcore). Handle non-PR triggers (push to main, workflow_dispatch on build) by deploying all registered types. Label-based resolution only applies to PR triggers. Part of #73 Phase 3. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent feccf16 commit e832401

2 files changed

Lines changed: 78 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 41 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/deploy.yml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,63 @@ on:
66
workflow_run:
77
workflows: [build]
88
types: [completed]
9+
workflow_dispatch:
10+
inputs:
11+
compute_type:
12+
description: "Compute type to deploy"
13+
required: true
14+
type: choice
15+
options:
16+
- all
17+
- agentcore
918
permissions: {}
1019
jobs:
1120
resolve-targets:
12-
if: github.event.workflow_run.conclusion == 'success'
21+
if: >-
22+
github.event_name == 'workflow_dispatch' ||
23+
github.event.workflow_run.conclusion == 'success'
1324
runs-on: ubuntu-latest
1425
permissions:
1526
actions: read
1627
pull-requests: read
1728
outputs:
1829
matrix: ${{ steps.targets.outputs.matrix }}
1930
has_targets: ${{ steps.targets.outputs.has_targets }}
20-
run_id: ${{ github.event.workflow_run.id }}
31+
run_id: ${{ steps.targets.outputs.run_id }}
2132
steps:
22-
- name: Resolve deploy targets from labels
33+
- name: Resolve deploy targets
2334
id: targets
2435
env:
2536
GH_TOKEN: ${{ github.token }}
37+
EVENT_NAME: ${{ github.event_name }}
2638
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
27-
EVENT_TYPE: ${{ github.event.workflow_run.event }}
39+
BUILD_EVENT_TYPE: ${{ github.event.workflow_run.event }}
2840
REPO: ${{ github.repository }}
2941
PR_NUMBER_FROM_EVENT: ${{ github.event.workflow_run.pull_requests[0].number }}
42+
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
43+
DISPATCH_COMPUTE_TYPE: ${{ inputs.compute_type }}
3044
run: |
3145
ALL_TYPES='["agentcore"]'
3246
33-
# Push to main always deploys all registered types
34-
if [[ "$HEAD_BRANCH" == "main" && "$EVENT_TYPE" == "push" ]]; then
47+
# workflow_dispatch: use input choice
48+
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
49+
if [[ "$DISPATCH_COMPUTE_TYPE" == "all" ]]; then
50+
echo "matrix=$ALL_TYPES" >> "$GITHUB_OUTPUT"
51+
else
52+
echo "matrix=[\"$DISPATCH_COMPUTE_TYPE\"]" >> "$GITHUB_OUTPUT"
53+
fi
54+
echo "has_targets=true" >> "$GITHUB_OUTPUT"
55+
# Find the latest successful build run for this branch
56+
RUN_ID=$(gh api "repos/$REPO/actions/workflows/build.yml/runs?branch=$(git branch --show-current 2>/dev/null || echo main)&status=success&per_page=1" --jq '.workflow_runs[0].id // empty')
57+
echo "run_id=${RUN_ID}" >> "$GITHUB_OUTPUT"
58+
exit 0
59+
fi
60+
61+
# workflow_run context from here on
62+
echo "run_id=${WORKFLOW_RUN_ID}" >> "$GITHUB_OUTPUT"
63+
64+
# Push to main or workflow_dispatch on build always deploys all
65+
if [[ "$HEAD_BRANCH" == "main" && ("$BUILD_EVENT_TYPE" == "push" || "$BUILD_EVENT_TYPE" == "workflow_dispatch") ]]; then
3566
echo "matrix=$ALL_TYPES" >> "$GITHUB_OUTPUT"
3667
echo "has_targets=true" >> "$GITHUB_OUTPUT"
3768
exit 0

0 commit comments

Comments
 (0)