-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (97 loc) · 3.52 KB
/
actions.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: actions
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lint:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: backend
args: --modules-download-mode=readonly
- name: Install dependencies
run: |
cd ${{ github.workspace }}/backend
go mod download
- name: Test
run: |
cd ${{ github.workspace }}/backend
go test -timeout=60s -race -covermode atomic -coverprofile=covprofile -coverpkg=./... ./tests
- name: Submit coverage
run: |
cd ${{ github.workspace }}/backend
go install github.com/mattn/goveralls@latest
$(go env GOPATH)/bin/goveralls -service=github -coverprofile=covprofile
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
needs: [lint]
strategy:
matrix:
arch: [amd64, arm64, armv7]
os: [linux]
include:
- { arch: amd64, goarch: amd64, goarm: "" }
- { arch: arm64, goarch: arm64, goarm: "" }
- { arch: armv7, goarch: arm, goarm: 7 }
steps:
- uses: actions/checkout@v3
- name: Set env variables
run: |
echo "REPOSITORY=ghcr.io/${REPOSITORY:-$GITHUB_REPOSITORY}-api" >> $GITHUB_ENV
echo "DOCKER_USER=${DOCKER_USER:-$GITHUB_ACTOR}" >> $GITHUB_ENV
env:
REPOSITORY: ${{ secrets.REPOSITORY }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
- name: Build image
run: docker build --build-arg VERSION=$GITHUB_REF:$GITHUB_SHA --build-arg GOARCH=${{ matrix.goarch }} --build-arg GOARM=${{ matrix.goarm }} -t $REPOSITORY:${{ matrix.arch }} -f Dockerfile.backend .
- name: Publish image
if: github.ref == 'refs/heads/master'
run: |
echo ${{ secrets.DOCKER_TOKEN }} | docker login ghcr.io -u $DOCKER_USER --password-stdin
docker push $REPOSITORY:${{ matrix.arch }}
manifest:
runs-on: ubuntu-latest
needs: [lint, build]
env:
DOCKER_CLI_EXPERIMENTAL: enabled
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Set env variables
run: |
echo "REPOSITORY=ghcr.io/${REPOSITORY:-$GITHUB_REPOSITORY}-api" >> $GITHUB_ENV
echo "DOCKER_USER=${DOCKER_USER:-$GITHUB_ACTOR}" >> $GITHUB_ENV
env:
REPOSITORY: ${{ secrets.REPOSITORY }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
- name: Publish manifest
run: |
echo ${{ secrets.DOCKER_TOKEN }} | docker login ghcr.io -u $DOCKER_USER --password-stdin
docker manifest create $REPOSITORY:latest $REPOSITORY:amd64 $REPOSITORY:arm64 $REPOSITORY:armv7
docker manifest annotate $REPOSITORY $REPOSITORY:amd64 --arch "amd64" --os "linux" --variant ""
docker manifest annotate $REPOSITORY $REPOSITORY:arm64 --arch "arm64" --os "linux" --variant ""
docker manifest annotate $REPOSITORY $REPOSITORY:armv7 --arch "arm" --os "linux" --variant "7"
docker manifest push $REPOSITORY