Skip to content

Commit caee369

Browse files
authored
Create staging-deploy.yml
1 parent dac93a9 commit caee369

File tree

1 file changed

+266
-0
lines changed

1 file changed

+266
-0
lines changed
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
name: Staging Deployment
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
branches: ["develop"]
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
15+
jobs:
16+
build-and-push:
17+
runs-on: ${{ matrix.runner }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
# Backend EE
23+
- service: backend-ee
24+
image_name: ${{ github.repository }}/digger-backend-ee
25+
dockerfile: Dockerfile_backend_ee
26+
context: .
27+
depot_project: kcld4zgwzx
28+
runner: ubuntu-latest
29+
30+
# Drift
31+
- service: drift
32+
image_name: ${{ github.repository }}/drift
33+
dockerfile: Dockerfile_drift
34+
context: .
35+
depot_project: f11hp4hlmg
36+
runner: ubuntu-latest
37+
38+
# Projects Refresh
39+
- service: projects-refresh
40+
image_name: ${{ github.repository }}/projects-refresh-service
41+
dockerfile: Dockerfile_bg_projects_refresh
42+
context: .
43+
depot_project: "p9zgmm1k3n"
44+
runner: ubuntu-latest
45+
46+
# UI
47+
- service: ui
48+
image_name: ${{ github.repository }}/taco-ui
49+
dockerfile: Dockerfile_ui
50+
context: .
51+
depot_project: n4w66j9g6t
52+
runner: ubuntu-larger
53+
54+
# Taco Statesman
55+
- service: taco-statesman
56+
image_name: ${{ github.repository }}/taco-statesman
57+
dockerfile: Dockerfile_statesman
58+
context: ./taco
59+
depot_project: q63j2g84tp
60+
runner: ubuntu-latest
61+
62+
# Taco Token Service
63+
- service: taco-token-service
64+
image_name: ${{ github.repository }}/taco-token-service
65+
dockerfile: Dockerfile_token_service
66+
context: ./taco
67+
depot_project: q63j2g84tp
68+
runner: ubuntu-latest
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
75+
- name: Generate staging tag
76+
id: tag
77+
run: |
78+
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
79+
STAGING_TAG="staging-${SHORT_SHA}"
80+
echo "tag=${STAGING_TAG}" >> $GITHUB_OUTPUT
81+
echo "Generated staging tag: ${STAGING_TAG}"
82+
83+
- name: Set up Docker Buildx
84+
uses: docker/setup-buildx-action@v3
85+
86+
- name: Log in to Container Registry
87+
uses: docker/login-action@v3
88+
with:
89+
registry: ${{ env.REGISTRY }}
90+
username: ${{ github.actor }}
91+
password: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Extract metadata
94+
id: docker-meta
95+
uses: docker/metadata-action@v5
96+
with:
97+
images: ${{ env.REGISTRY }}/${{ matrix.image_name }}
98+
tags: |
99+
type=raw,value=${{ steps.tag.outputs.tag }}
100+
type=raw,value=${{ steps.tag.outputs.tag }}-${{ matrix.service }}
101+
102+
- name: Setup Depot
103+
if: matrix.depot_project != ''
104+
uses: depot/setup-action@v1
105+
106+
- name: Build and push Docker image (Depot)
107+
if: matrix.depot_project != ''
108+
uses: depot/build-push-action@v1
109+
with:
110+
project: ${{ matrix.depot_project }}
111+
token: ${{ secrets.DEPOT_TOKEN }}
112+
context: ${{ matrix.context }}
113+
file: ${{ matrix.context }}/${{ matrix.dockerfile }}
114+
push: true
115+
platforms: linux/amd64,linux/arm64
116+
tags: ${{ steps.docker-meta.outputs.tags }}
117+
labels: ${{ steps.docker-meta.outputs.labels }}
118+
cache-from: type=gha
119+
cache-to: type=gha,mode=max
120+
build-args: |
121+
COMMIT_SHA=${{ github.sha }}
122+
VERSION=${{ steps.tag.outputs.tag }}
123+
124+
- name: Build and push Docker image (Standard)
125+
if: matrix.depot_project == ''
126+
uses: docker/build-push-action@v5
127+
with:
128+
context: ${{ matrix.context }}
129+
file: ${{ matrix.context }}/${{ matrix.dockerfile }}
130+
push: true
131+
platforms: linux/amd64,linux/arm64
132+
tags: ${{ steps.docker-meta.outputs.tags }}
133+
labels: ${{ steps.docker-meta.outputs.labels }}
134+
build-args: |
135+
COMMIT_SHA=${{ github.sha }}
136+
VERSION=${{ steps.tag.outputs.tag }}
137+
138+
- name: Output image info
139+
run: |
140+
echo "✅ Built and pushed: ${{ env.REGISTRY }}/${{ matrix.image_name }}:${{ steps.tag.outputs.tag }}"
141+
echo "Service: ${{ matrix.service }}"
142+
echo "Tag: ${{ steps.tag.outputs.tag }}"
143+
echo "Commit: ${{ github.sha }}"
144+
echo "PR: #${{ github.event.pull_request.number }}"
145+
146+
update-helm-chart:
147+
needs: build-and-push
148+
runs-on: ubuntu-latest
149+
if: success()
150+
steps:
151+
- name: Generate staging tag
152+
id: tag
153+
run: |
154+
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
155+
STAGING_TAG="staging-${SHORT_SHA}"
156+
echo "tag=${STAGING_TAG}" >> $GITHUB_OUTPUT
157+
echo "Generated staging tag: ${STAGING_TAG}"
158+
159+
- name: Checkout helm charts repo
160+
uses: actions/checkout@v4
161+
with:
162+
repository: diggerhq/opentaco-helm-charts
163+
token: ${{ secrets.HELM_CHARTS_PAT }}
164+
ref: main
165+
166+
- name: Install yq
167+
run: |
168+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
169+
sudo chmod +x /usr/local/bin/yq
170+
171+
- name: Update values-staging.yaml
172+
run: |
173+
STAGING_TAG="${{ steps.tag.outputs.tag }}"
174+
VALUES_FILE="opentaco/values-staging.yaml"
175+
176+
if [ ! -f "$VALUES_FILE" ]; then
177+
echo "Error: $VALUES_FILE not found"
178+
exit 1
179+
fi
180+
181+
echo "Updating values-staging.yaml with staging tag: ${STAGING_TAG}"
182+
183+
# Update all service image tags
184+
yq eval ".taco-orchestrator.digger.image.tag = \"${STAGING_TAG}\"" -i "$VALUES_FILE"
185+
yq eval ".taco-drift.drift.image.tag = \"${STAGING_TAG}\"" -i "$VALUES_FILE"
186+
yq eval ".taco-ui.ui.image.tag = \"${STAGING_TAG}\"" -i "$VALUES_FILE"
187+
yq eval ".taco-statesman.taco.image.tag = \"${STAGING_TAG}\"" -i "$VALUES_FILE"
188+
yq eval ".taco-token-service.tokenService.image.tag = \"${STAGING_TAG}\"" -i "$VALUES_FILE"
189+
190+
echo "Updated successfully!"
191+
echo "---"
192+
echo "Updated tags:"
193+
yq eval ".taco-orchestrator.digger.image.tag" "$VALUES_FILE"
194+
yq eval ".taco-drift.drift.image.tag" "$VALUES_FILE"
195+
yq eval ".taco-ui.ui.image.tag" "$VALUES_FILE"
196+
yq eval ".taco-statesman.taco.image.tag" "$VALUES_FILE"
197+
yq eval ".taco-token-service.tokenService.image.tag" "$VALUES_FILE"
198+
199+
- name: Commit and push changes
200+
run: |
201+
git config user.name "github-actions[bot]"
202+
git config user.email "github-actions[bot]@users.noreply.github.com"
203+
204+
STAGING_TAG="${{ steps.tag.outputs.tag }}"
205+
PR_NUMBER="${{ github.event.pull_request.number }}"
206+
COMMIT="${{ github.sha }}"
207+
208+
git add opentaco/values-staging.yaml
209+
210+
if git diff --staged --quiet; then
211+
echo "No changes to commit"
212+
exit 0
213+
fi
214+
215+
# Create commit message
216+
git commit -m "chore(staging): update all services to ${STAGING_TAG}" \
217+
-m "Automated update from staging deployment." \
218+
-m "" \
219+
-m "PR: #${PR_NUMBER}" \
220+
-m "Commit: ${COMMIT}" \
221+
-m "Staging Tag: ${STAGING_TAG}"
222+
223+
git push
224+
225+
echo "✅ Successfully updated helm chart values-staging.yaml with ${STAGING_TAG}"
226+
227+
summary:
228+
needs: [build-and-push, update-helm-chart]
229+
runs-on: ubuntu-latest
230+
if: always()
231+
steps:
232+
- name: Deployment Summary
233+
run: |
234+
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
235+
STAGING_TAG="staging-${SHORT_SHA}"
236+
237+
echo "## 🚀 Staging Deployment Summary" >> $GITHUB_STEP_SUMMARY
238+
echo "" >> $GITHUB_STEP_SUMMARY
239+
echo "**PR:** #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY
240+
echo "**Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
241+
echo "**Staging Tag:** \`${STAGING_TAG}\`" >> $GITHUB_STEP_SUMMARY
242+
echo "" >> $GITHUB_STEP_SUMMARY
243+
echo "### Built Images" >> $GITHUB_STEP_SUMMARY
244+
echo "" >> $GITHUB_STEP_SUMMARY
245+
echo "| Service | Image |" >> $GITHUB_STEP_SUMMARY
246+
echo "|---------|-------|" >> $GITHUB_STEP_SUMMARY
247+
echo "| Backend EE | \`ghcr.io/${{ github.repository }}/digger-backend-ee:${STAGING_TAG}\` |" >> $GITHUB_STEP_SUMMARY
248+
echo "| Drift | \`ghcr.io/${{ github.repository }}/drift:${STAGING_TAG}\` |" >> $GITHUB_STEP_SUMMARY
249+
echo "| Projects Refresh | \`ghcr.io/${{ github.repository }}/projects-refresh-service:${STAGING_TAG}\` |" >> $GITHUB_STEP_SUMMARY
250+
echo "| UI | \`ghcr.io/${{ github.repository }}/taco-ui:${STAGING_TAG}\` |" >> $GITHUB_STEP_SUMMARY
251+
echo "| Taco Statesman | \`ghcr.io/${{ github.repository }}/taco-statesman:${STAGING_TAG}\` |" >> $GITHUB_STEP_SUMMARY
252+
echo "| Taco Token Service | \`ghcr.io/${{ github.repository }}/taco-token-service:${STAGING_TAG}\` |" >> $GITHUB_STEP_SUMMARY
253+
echo "" >> $GITHUB_STEP_SUMMARY
254+
echo "### Pull Images" >> $GITHUB_STEP_SUMMARY
255+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
256+
echo "docker pull ghcr.io/${{ github.repository }}/digger-backend-ee:${STAGING_TAG}" >> $GITHUB_STEP_SUMMARY
257+
echo "docker pull ghcr.io/${{ github.repository }}/drift:${STAGING_TAG}" >> $GITHUB_STEP_SUMMARY
258+
echo "docker pull ghcr.io/${{ github.repository }}/projects-refresh-service:${STAGING_TAG}" >> $GITHUB_STEP_SUMMARY
259+
echo "docker pull ghcr.io/${{ github.repository }}/taco-ui:${STAGING_TAG}" >> $GITHUB_STEP_SUMMARY
260+
echo "docker pull ghcr.io/${{ github.repository }}/taco-statesman:${STAGING_TAG}" >> $GITHUB_STEP_SUMMARY
261+
echo "docker pull ghcr.io/${{ github.repository }}/taco-token-service:${STAGING_TAG}" >> $GITHUB_STEP_SUMMARY
262+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
263+
echo "" >> $GITHUB_STEP_SUMMARY
264+
echo "### Helm Chart Updated ✅" >> $GITHUB_STEP_SUMMARY
265+
echo "The helm chart \`values-staging.yaml\` has been automatically updated in the [opentaco-helm-charts](https://github.com/diggerhq/opentaco-helm-charts) repository with tag \`${STAGING_TAG}\`." >> $GITHUB_STEP_SUMMARY
266+

0 commit comments

Comments
 (0)