Skip to content

Commit 382c551

Browse files
refactor(ci): move deploy input to build.yml, use deploy-intent artifact
build.yml now owns the deploy decision via workflow_dispatch choice input: - "-" (default): no deploy - "agentcore": deploy agentcore after build Build always writes a deploy-intent.json artifact encoding the decision: - push to main: intent = compute_type (deploy) - workflow_dispatch with choice: intent = selected value - pull_request: intent = "labels" (defer to deploy.yml label check) - anything else: intent = "-" (no deploy) deploy.yml simplified to a pure consumer: - Removes workflow_dispatch trigger (single entry point is build.yml) - Downloads deploy-intent.json from triggering build run - Reads intent: "-" = skip, "labels" = check PR labels, else = deploy Part of #73 Phase 3. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e832401 commit 382c551

2 files changed

Lines changed: 87 additions & 64 deletions

File tree

.github/workflows/build.yml

Lines changed: 42 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: 45 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,91 +6,73 @@ 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
189
permissions: {}
1910
jobs:
2011
resolve-targets:
21-
if: >-
22-
github.event_name == 'workflow_dispatch' ||
23-
github.event.workflow_run.conclusion == 'success'
12+
if: github.event.workflow_run.conclusion == 'success'
2413
runs-on: ubuntu-latest
2514
permissions:
2615
actions: read
2716
pull-requests: read
2817
outputs:
2918
matrix: ${{ steps.targets.outputs.matrix }}
3019
has_targets: ${{ steps.targets.outputs.has_targets }}
31-
run_id: ${{ steps.targets.outputs.run_id }}
20+
run_id: ${{ github.event.workflow_run.id }}
3221
steps:
22+
- name: Download deploy intent
23+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
24+
with:
25+
name: deploy-intent
26+
run-id: ${{ github.event.workflow_run.id }}
27+
github-token: ${{ github.token }}
28+
3329
- name: Resolve deploy targets
3430
id: targets
3531
env:
3632
GH_TOKEN: ${{ github.token }}
37-
EVENT_NAME: ${{ github.event_name }}
38-
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
39-
BUILD_EVENT_TYPE: ${{ github.event.workflow_run.event }}
4033
REPO: ${{ github.repository }}
4134
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 }}
4435
run: |
4536
ALL_TYPES='["agentcore"]'
37+
INTENT=$(jq -r '.deploy' deploy-intent.json)
38+
echo "Deploy intent from build: $INTENT"
4639
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
66-
echo "matrix=$ALL_TYPES" >> "$GITHUB_OUTPUT"
67-
echo "has_targets=true" >> "$GITHUB_OUTPUT"
68-
exit 0
69-
fi
70-
71-
# For PRs, look up labels via API
72-
if [[ -z "$PR_NUMBER_FROM_EVENT" ]]; then
73-
echo "matrix=[]" >> "$GITHUB_OUTPUT"
74-
echo "has_targets=false" >> "$GITHUB_OUTPUT"
75-
exit 0
76-
fi
40+
case "$INTENT" in
41+
-)
42+
echo "matrix=[]" >> "$GITHUB_OUTPUT"
43+
echo "has_targets=false" >> "$GITHUB_OUTPUT"
44+
;;
45+
labels)
46+
# PR-triggered build — check labels
47+
if [[ -z "$PR_NUMBER_FROM_EVENT" ]]; then
48+
echo "matrix=[]" >> "$GITHUB_OUTPUT"
49+
echo "has_targets=false" >> "$GITHUB_OUTPUT"
50+
exit 0
51+
fi
7752
78-
LABELS=$(gh api "repos/$REPO/pulls/$PR_NUMBER_FROM_EVENT" --jq '[.labels[].name]')
53+
LABELS=$(gh api "repos/$REPO/pulls/$PR_NUMBER_FROM_EVENT" --jq '[.labels[].name]')
7954
80-
if echo "$LABELS" | jq -e 'index("deploy:*")' > /dev/null 2>&1; then
81-
echo "matrix=$ALL_TYPES" >> "$GITHUB_OUTPUT"
82-
echo "has_targets=true" >> "$GITHUB_OUTPUT"
83-
elif echo "$LABELS" | jq -e '[.[] | select(startswith("deploy:"))] | length > 0' > /dev/null 2>&1; then
84-
TYPES=$(echo "$LABELS" | jq -c '[.[] | select(startswith("deploy:")) | ltrimstr("deploy:")]')
85-
echo "matrix=$TYPES" >> "$GITHUB_OUTPUT"
86-
echo "has_targets=true" >> "$GITHUB_OUTPUT"
87-
elif echo "$LABELS" | jq -e 'index("deploy")' > /dev/null 2>&1; then
88-
echo "matrix=$ALL_TYPES" >> "$GITHUB_OUTPUT"
89-
echo "has_targets=true" >> "$GITHUB_OUTPUT"
90-
else
91-
echo "matrix=[]" >> "$GITHUB_OUTPUT"
92-
echo "has_targets=false" >> "$GITHUB_OUTPUT"
93-
fi
55+
if echo "$LABELS" | jq -e 'index("deploy:*")' > /dev/null 2>&1; then
56+
echo "matrix=$ALL_TYPES" >> "$GITHUB_OUTPUT"
57+
echo "has_targets=true" >> "$GITHUB_OUTPUT"
58+
elif echo "$LABELS" | jq -e '[.[] | select(startswith("deploy:"))] | length > 0' > /dev/null 2>&1; then
59+
TYPES=$(echo "$LABELS" | jq -c '[.[] | select(startswith("deploy:")) | ltrimstr("deploy:")]')
60+
echo "matrix=$TYPES" >> "$GITHUB_OUTPUT"
61+
echo "has_targets=true" >> "$GITHUB_OUTPUT"
62+
elif echo "$LABELS" | jq -e 'index("deploy")' > /dev/null 2>&1; then
63+
echo "matrix=$ALL_TYPES" >> "$GITHUB_OUTPUT"
64+
echo "has_targets=true" >> "$GITHUB_OUTPUT"
65+
else
66+
echo "matrix=[]" >> "$GITHUB_OUTPUT"
67+
echo "has_targets=false" >> "$GITHUB_OUTPUT"
68+
fi
69+
;;
70+
*)
71+
# Specific compute_type from push-to-main or workflow_dispatch
72+
echo "matrix=[\"$INTENT\"]" >> "$GITHUB_OUTPUT"
73+
echo "has_targets=true" >> "$GITHUB_OUTPUT"
74+
;;
75+
esac
9476
9577
deploy:
9678
needs: resolve-targets

0 commit comments

Comments
 (0)