This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
81 lines (76 loc) · 2.22 KB
/
Copy pathgo.yml
File metadata and controls
81 lines (76 loc) · 2.22 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
71
72
73
74
75
76
77
78
79
80
81
name: Go
on:
push:
branches:
- master
tags:
- v*
pull_request:
env:
IMAGE_NAME: code42software/dir2consul
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.15.5
- name: Check out Source Code
uses: actions/checkout@v3
- name: Get dependencies
run: go mod download
- name: Format
run: go fmt .
- name: Lint
run: |
go get -u golang.org/x/lint/golint
golint -set_exit_status ./...
- name: Errcheck
run: |
go get -u github.com/kisielk/errcheck
errcheck ./...
- name: Test
run: |
go test ./...
go test -race ./...
coverage:
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.15.5
- name: Check out Source Code
uses: actions/checkout@v3
- name: Measure Coverage
run: go test -v -covermode=atomic -coverprofile=coverage.out ./...
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.out
publish:
needs: [test]
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Check out Source Code
uses: actions/checkout@v3
- name: Log in to Docker Hub
run: echo "${{ secrets.DockerHubToken }}" | docker login -u ${{ secrets.DockerHubUsername }} --password-stdin
- name: Build and Push Docker Image
run: |
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
IMAGE_ID=$(echo $IMAGE_NAME | tr '[A-Z]' '[a-z]')
VCS_REF=${{ github.sha }}
VCS_URL=https://github.com/${{ github.repository }}
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[ "$VERSION" == "master" ] && VERSION=rc
docker build . \
--build-arg BUILD_DATE=$BUILD_DATE \
--build-arg VCS_REF=$VCS_REF \
--build-arg VCS_URL=$VCS_URL \
--build-arg VERSION=$VERSION \
--file Dockerfile --tag $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION