-
Notifications
You must be signed in to change notification settings - Fork 50
62 lines (52 loc) · 1.53 KB
/
dev-deploy.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
name: Dev Deployment
on:
workflow_dispatch:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
if: github.event.repository.fork == false
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t golang_backend .
- name: Save and compress Docker image
run: docker save golang_backend | gzip > golang_backend.tar.gz
- name: Upload Docker image
uses: actions/upload-artifact@v2
with:
name: golang_backend
path: golang_backend.tar.gz
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: "development"
url: ${{ vars.URL }}
steps:
- name: Download Docker image
uses: actions/download-artifact@v2
with:
name: golang_backend
path: .
- name: Copy image to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: golang_backend.tar.gz
target: "/tmp"
- name: Deploy on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
gunzip -c /tmp/golang_backend.tar.gz | docker load
rm -f /tmp/golang_backend.tar.gz
cd ~/hng_boilerplate_golang_web
docker compose -p golang up -d