This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
83 lines (64 loc) · 1.92 KB
/
continuous_integration.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Continuous Integration
on:
- push
- pull_request
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Spin up a detatched Postgress image
run: docker run --detach --name postgres -p 5432:5432 -v $(pwd)/db:/data -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres
- name: Get dependencies
run: go get ./...
- name: Build
run: go build .
- name: Initialize database
run: docker exec postgres psql -f /data/db.sql -U postgres
- name: Run Tests
run: POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres go test -v ./...
- name: Run docker build
run: docker build .
security-scanning:
name: Security Scanning
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: ./...
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Linting
run: docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.24.0 golangci-lint run -v
publishing:
name: Publishing
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
- security-scanning
- linting
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Push docker image
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
repository: ${{ github.repository }}/api-backend
tag_with_ref: true
tags: latest