forked from anydistro/bxt
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (58 loc) · 2.16 KB
/
build.yml
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
name: Build and deploy to testing server
on: [push, pull_request]
jobs:
build-docker:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Build production environment using docker-compose
run: |
docker compose -f docker-compose.yml -f docker-compose.caddy.yml build production
- name: Save Docker image as a tarball
run: docker save bxt_production:latest -o bxt-production.tar
- name: Upload Docker image to artifacts
uses: actions/upload-artifact@v4
with:
name: bxt-production-image
path: |
bxt-production.tar
docker-compose.yml
docker-compose.caddy.yml
deploy-ssh:
name: Deploy to server using ssh
needs: build-docker
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.repository == 'anydistro/bxt'
steps:
- name: Download Docker image from artifacts
uses: actions/download-artifact@v4
with:
name: bxt-production-image
path: distfiles
- name: Transfer Docker image to server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.DEPLOYMENT_SERVER_HOST }}
username: ${{ secrets.DEPLOYMENT_SERVER_USER }}
key: ${{ secrets.DEPLOYMENT_SERVER_SSH_KEY }}
source: distfiles/*
target: "/tmp/bxt/"
- name: Deploy Docker image on server
uses: appleboy/ssh-action@v1.0.3
env:
CADDY_HOST: ${{ secrets.DEPLOYMENT_SERVER_HOST }}
with:
host: ${{ secrets.DEPLOYMENT_SERVER_HOST }}
username: ${{ secrets.DEPLOYMENT_SERVER_USER }}
key: ${{ secrets.DEPLOYMENT_SERVER_SSH_KEY }}
envs: CADDY_HOST
script: |
cd /tmp/bxt/distfiles/
docker compose -f docker-compose.yml -f docker-compose.caddy.yml down production || true
docker load -i bxt-production.tar
docker compose -f docker-compose.yml -f docker-compose.caddy.yml -p bxt up -d production