Skip to content

Commit 6639d4b

Browse files
committed
Add actions code
1 parent d8d80a0 commit 6639d4b

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)