-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (70 loc) · 2.24 KB
/
ci.yml
File metadata and controls
70 lines (70 loc) · 2.24 KB
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
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@master
- name: Run GolangCI-Lint Action
uses: actions-contrib/golangci-lint@v1
with:
args: run ./... --exclude-use-default
test:
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@master
- uses: whoan/docker-build-with-cache-action@v5
with:
username: vaihtovirta
password: "${{ secrets.GITHUB_TOKEN }}"
registry: docker.pkg.github.com
image_name: timecodes-api_base
push_image_and_stages: false
pull_image_and_stages: false
- name: Build docker image for tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp .env.test .env
docker login docker.pkg.github.com -u vaihtovirta -p $GITHUB_TOKEN
docker network create traefik-public
docker-compose build --pull app_test
- name: Run tests
run: docker-compose run --rm app_test go test ./... -covermode=count -coverprofile=tmp/coverage.out
- name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1.0.2
with:
infile: tmp/coverage.out
outfile: coverage.lcov
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: coverage.lcov
deployment:
if: github.ref == 'refs/heads/master'
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- name: Connect by ssh and rebuild docker image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
passphrase: ${{ secrets.PASSPHRASE }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd /home/deploy/applications/timecodes/timecodes-api
git fetch --all
git reset --hard origin/master
export $(egrep -v '^#' .env.production | xargs)
docker-compose pull app
docker-compose up -d app