-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (68 loc) · 2.24 KB
/
build+deploy.yaml
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
name: Build and Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Add SHORT_SHA env property with commit short sha
id: get_short_sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Build apps
run: yarn build:all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Dockerize client
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.client
context: .
push: true
tags: fllsk/tms-client:latest, fllsk/tms-client:sha-${{steps.get_short_sha.outputs.SHORT_SHA}}
- name: Dockerize server
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.server
context: .
push: true
tags: fllsk/tms-server:latest, fllsk/tms-server:sha-${{steps.get_short_sha.outputs.SHORT_SHA}}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Copy docker-compose.yaml to production server
# made by a random appleboy to copy specified file to target server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ vars.DEPLOY_HOST }}
username: ${{ vars.DEPLOY_HOST_USERNAME }}
key: ${{ secrets.DEPLOY_HOST_SSH_KEY }}
source: 'docker-compose.yaml'
target: '~/.deploy/'
- name: Run docker-compose up on production server
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ vars.DEPLOY_HOST }}
username: ${{ vars.DEPLOY_HOST_USERNAME }}
key: ${{ secrets.DEPLOY_HOST_SSH_KEY }}
script: |
cd ~/
sudo deploy-compose.sh deploy