-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (37 loc) · 1.17 KB
/
test-build-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
name: Go Backend CI/CD
on:
push:
branches:
- main
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Build Test Docker Image
run: docker build -t jokil/esefexapi:test -f Dockerfile.test .
- name: Run Tests in Docker Container
run: doocker run jokil/esefexapi:test go test ./...
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Build Prod Docker Image
run: docker build -t jokil/esefexapi:latest -f Dockerfile .
- name: Login to Docker Registry
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker Image
- run: docker push jokil/esefexapi:latest
- name: Deploy to Production
run: |
# SSH into your production server
ssh [email protected] "cd /api && \
docker-compose down && \
docker-compose pull && \
docker-compose up -d"