-
Notifications
You must be signed in to change notification settings - Fork 16
88 lines (74 loc) · 2.19 KB
/
ci.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
84
85
86
87
88
name: For each commit and PR
on:
push:
branches:
- "*"
tags-ignore:
- "v*"
pull_request:
env:
CGO_ENABLED: 0
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: goimports
run: go install golang.org/x/tools/cmd/goimports@latest && goimports -d . | (! grep .)
- name: make vet
run: make vet
- name: lint
run: make lint
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Unit test
run: make test
- name: Upload coverage report
run: bash <(curl -s https://codecov.io/bash)
build:
runs-on: ubuntu-latest
needs:
- verify
- test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to quay.io
uses: docker/login-action@v3
if: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Docker build meta
id: image-meta
uses: docker/metadata-action@v5
with:
images: quay.io/tinkerbell/rufio
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch,enable=${{ !startsWith(github.ref, 'refs/heads/main') }}
type=sha
- name: Docker build quay.io/tinkerbell/rufio
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
cache-from: type=registry,ref=quay.io/tinkerbell/rufio:latest
tags: ${{ steps.image-meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
push: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }}