-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (44 loc) · 1.45 KB
/
main.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
name: 🚀 CI / CD Actions For React Apps Into Server
on:
push:
branches:
- main
jobs:
deploy:
name: 🚀 Deploy to server
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout Code
uses: actions/checkout@v3
- name: 📂 Copy file into server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
source: "."
target: "/home/pptik-wbs/frontend/web-panic-button112"
- name: 🧹 Clean up old images
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
dangling_images=$(sudo docker images -f "dangling=true" -q)
if [ -n "$dangling_images" ]; then
sudo docker rmi $dangling_images || true
fi
sudo docker container prune -f
- name: 🐳 Build Docker compose
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cd /home/pptik-wbs/frontend/web-panic-button112
sudo docker compose up -d --build