-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (162 loc) · 5.74 KB
/
Copy pathrun_cd.yml
File metadata and controls
191 lines (162 loc) · 5.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Continuous Deployment (CD)
on:
workflow_dispatch:
inputs:
model_name:
description: "Model to deploy"
required: true
type: choice
options:
- all
- smollm3-3b-smashed
- phi4-reasoning-plus-unsloth
- flux-fast-lora-hotswap
- flux-fast-lora-hotswap-img2img
- gemma3-torchao-quant-sparse
permissions:
contents: read
env:
PYTHON_VERSION: "3.12"
# --------------------------------------------------
# 🎯 Setup (resolve model matrix)
# --------------------------------------------------
jobs:
setup:
runs-on: ubuntu-22.04
outputs:
models: ${{ steps.matrix.outputs.models }}
steps:
- id: matrix
run: |
if [ "${{ github.event.inputs.model_name }}" = "all" ]; then
echo 'models=["smollm3-3b-smashed","phi4-reasoning-plus-unsloth","flux-fast-lora-hotswap","flux-fast-lora-hotswap-img2img","gemma3-torchao-quant-sparse"]' >> $GITHUB_OUTPUT
else
echo 'models=["${{ github.event.inputs.model_name }}"]' >> $GITHUB_OUTPUT
fi
# --------------------------------------------------
# 🚀 Deploy (authoritative)
# --------------------------------------------------
deploy:
name: 🚀 Deploy (${{ matrix.model }})
needs: setup
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
matrix:
model: ${{ fromJson(needs.setup.outputs.models) }}
fail-fast: false
outputs:
candidate_model_id: ${{ steps.deploy.outputs.candidate_model_id }}
env:
MODEL_NAME: ${{ matrix.model }}
REPLICATE_CLI_AUTH_TOKEN: ${{ secrets.REPLICATE_CLI_AUTH_TOKEN }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
steps:
- uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: true
android: true
dotnet: true
haskell: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: replicate/setup-cog@v2
with:
cog-version: "v0.16.9"
token: ${{ secrets.REPLICATE_CLI_AUTH_TOKEN }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ matrix.model }}-${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
- name: Install deps
run: make install-deps
- name: Deploy model
id: deploy
env:
REPLICATE_CLI_AUTH_TOKEN: ${{ secrets.REPLICATE_CLI_AUTH_TOKEN }}
run: |
set -e
make deploy || exit 1
# Best-effort metadata only
if [ -f /tmp/model_id.txt ]; then
CID=$(cat /tmp/model_id.txt | xargs)
echo "ℹ️ Candidate model ID: $CID"
echo "candidate_model_id=$CID" >> "$GITHUB_OUTPUT"
else
echo "ℹ️ No model ID emitted (allowed)"
fi
# --------------------------------------------------
# 🧪 Integration (blocking gate)
# --------------------------------------------------
integration:
name: 🧪 Integration (${{ matrix.model }})
needs: [setup, deploy]
runs-on: ubuntu-22.04
timeout-minutes: 45
strategy:
matrix:
model: ${{ fromJson(needs.setup.outputs.models) }}
fail-fast: false
env:
MODEL_NAME: ${{ matrix.model }}
CANDIDATE_MODEL_ID: ${{ needs.deploy.outputs.candidate_model_id }}
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ matrix.model }}-${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
- run: make install-deps
- run: make integration
# --------------------------------------------------
# 🐦 Canary (async, non-blocking)
# --------------------------------------------------
trigger-canary:
name: 🐦 Trigger Canary
needs: [deploy, integration]
runs-on: ubuntu-22.04
if: needs.integration.result == 'success'
steps:
- uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'run_canary.yml',
ref: context.ref,
inputs: {
model_name: '${{ github.event.inputs.model_name }}',
candidate_model_id: '${{ needs.deploy.outputs.candidate_model_id }}'
}
})
# --------------------------------------------------
# 📊 Summary (observability only)
# --------------------------------------------------
summary:
name: 📊 Deployment Summary
needs: [deploy, integration, trigger-canary]
runs-on: ubuntu-22.04
if: always()
steps:
- run: |
echo "## 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Stage | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Deploy | ${{ needs.deploy.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Integration | ${{ needs.integration.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Canary Trigger | ${{ needs.trigger-canary.result }} |" >> $GITHUB_STEP_SUMMARY
if [ -n "${{ needs.deploy.outputs.candidate_model_id }}" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Candidate Model ID:** \`${{ needs.deploy.outputs.candidate_model_id }}\`" >> $GITHUB_STEP_SUMMARY
fi