-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (55 loc) · 1.51 KB
/
makefile.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
67
name: Go Build, Test, and Deploy
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.4
- name: Install Make
run: |
sudo apt update
sudo apt install -y make
- name: Build
run: make build
- name: Install dependencies
run: go mod tidy
- name: Run tests
run: go test -v ./...
deploy-to-ec2:
name: Deploy to EC2
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout the files
uses: actions/checkout@v2
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }}
REMOTE_HOST: ${{ secrets.HOST_DNS }}
REMOTE_USER: ${{ secrets.USERNAME }}
TARGET: ${{ secrets.TARGET_DIR }}
- name: Connect to EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_DNS }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd any-fashion-gin-clean-code
git pull
sudo docker-compose down # Stop running containers
sudo docker-compose build
sudo docker-compose-up # Recreate and start containers