-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (86 loc) · 2.61 KB
/
ci.yml
File metadata and controls
106 lines (86 loc) · 2.61 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: CI-workflow
on:
push:
branches: ["main"]
tags: ["v*.*.*"]
env:
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.23.x"]
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Setup go-task
run: go install github.com/go-task/task/v3/cmd/task@latest
- name: Setup golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Install dependencies
run: go mod download
- name: Build
run: task build
- name: Lint
run: task lint
- name: Test cov
run: task test-cov-html
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: go-results-${{ matrix.go-version }}
path: cov/coverage.html
build-and-push-image:
runs-on: ubuntu-latest
needs: run-tests
environment: prod
permissions:
id-token: write
attestations: write
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set variables
run: |
VER=$(cat VERSION)
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=${{ env.VERSION }}
- name: Log in to dockerhub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
no-cache: true
provenance: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update dockerhub description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ github.repository }}
short-description: ${{ github.event.repository.description }}
enable-url-completion: true