Skip to content

Commit f4b263b

Browse files
committed
Add actions code
1 parent d8d80a0 commit f4b263b

1 file changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Deploy AI Studio
2+
3+
on:
4+
push:
5+
branches: ["WB-229-swarm-alignment"]
6+
workflow_dispatch:
7+
inputs:
8+
image_tag:
9+
description: 'Image tag (defaults to short SHA)'
10+
required: false
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
env:
17+
REGISTRY: synergycodes.azurecr.io
18+
APP: wb-ai-studio
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
image_tag: ${{ steps.tag.outputs.value }}
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Resolve image tag
31+
id: tag
32+
run: |
33+
TAG="${{ inputs.image_tag || github.sha }}"
34+
echo "value=${TAG::7}" >> "$GITHUB_OUTPUT"
35+
36+
- name: Log in to Azure
37+
uses: azure/login@v2
38+
with:
39+
client-id: ${{ vars.AZURE_CLIENT_ID }}
40+
tenant-id: ${{ vars.AZURE_TENANT_ID }}
41+
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
42+
43+
- name: Log in to ACR
44+
run: az acr login --name synergycodes
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Build and push runtime image
50+
uses: docker/build-push-action@v6
51+
with:
52+
context: .
53+
file: deploy/ai-studio/Dockerfile
54+
target: runtime
55+
push: true
56+
tags: |
57+
${{ env.REGISTRY }}/${{ env.APP }}:${{ steps.tag.outputs.value }}-runtime
58+
${{ env.REGISTRY }}/${{ env.APP }}:latest-runtime
59+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.APP }}:latest-runtime
60+
cache-to: type=inline
61+
62+
- name: Build and push web image
63+
uses: docker/build-push-action@v6
64+
with:
65+
context: .
66+
file: deploy/ai-studio/Dockerfile
67+
target: web
68+
push: true
69+
tags: |
70+
${{ env.REGISTRY }}/${{ env.APP }}:${{ steps.tag.outputs.value }}-web
71+
${{ env.REGISTRY }}/${{ env.APP }}:latest-web
72+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.APP }}:latest-web
73+
cache-to: type=inline
74+
build-args: |
75+
VITE_BACKEND_URL=
76+
77+
deploy:
78+
runs-on: ubuntu-latest
79+
needs: build-and-push
80+
81+
steps:
82+
- name: Refresh docker compose on Azure VM
83+
uses: appleboy/ssh-action@v1
84+
with:
85+
host: ${{ secrets.VM_HOST }}
86+
username: ${{ secrets.VM_USER }}
87+
key: ${{ secrets.VM_SSH_KEY }}
88+
script: |
89+
set -e
90+
DEPLOY_DIR=${{ secrets.VM_DEPLOY_DIR }}
91+
92+
az acr login --name synergycodes
93+
94+
docker compose -f ${DEPLOY_DIR}/docker-compose.yml pull
95+
docker compose -f ${DEPLOY_DIR}/docker-compose.yml up -d --no-build --force-recreate

0 commit comments

Comments
 (0)