This repository was archived by the owner on Apr 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (75 loc) · 2.4 KB
/
swarm-deploy.yml
File metadata and controls
90 lines (75 loc) · 2.4 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
name: Deploy to Docker Swarm
on:
push:
branches:
- main
env:
IMAGE_NAME: ghcr.io/wheels-dev/wheels-dev
REGISTRY: ghcr.io
jobs:
build:
name: Build & Push Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Copy swarm config files to root
run: |
cp ./deploy/swarm/.env ./
cp ./deploy/swarm/dockerfile ./
- name: Install CommandBox
uses: Ortus-Solutions/setup-commandbox@v2.0.1
with:
forgeboxAPIKey: ${{ secrets.FORGEBOX_API_KEY }}
- name: Install wheels-cli and dependencies
run: |
box install wheels-cli
box install
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy to Swarm
runs-on: [self-hosted, Linux, swarm]
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to GHCR
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_ACTOR: ${{ github.actor }}
run: |
echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GH_ACTOR" --password-stdin
- name: Deploy stack to swarm
run: |
# Use commit SHA tag to force Swarm to pull the new image
sed -i "s|ghcr.io/wheels-dev/wheels-dev:latest|ghcr.io/wheels-dev/wheels-dev:${GITHUB_SHA}|" deploy/swarm/docker-compose.yml
docker stack deploy \
--with-registry-auth \
-c deploy/swarm/docker-compose.yml \
wheels-dev
- name: Verify deployment
run: |
echo "Waiting for services to stabilize..."
sleep 30
docker service ls
echo ""
echo "Checking wheels-dev service replicas..."
docker service ps wheels-dev_wheels-dev --no-trunc