Skip to content

Commit 3e62b0c

Browse files
committed
docker build action
1 parent 8e15a0d commit 3e62b0c

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
- name: Test
3030
run: make test test-generate
3131

32+
build:
33+
runs-on: ubuntu-latest
34+
steps:
3235
- name: Build
3336
run: |
3437
GOOS=linux GOARCH=amd64 make build

.github/workflows/docker.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Docker build
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
release:
9+
types:
10+
- published
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
16+
jobs:
17+
docker-build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Setup Go
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version-file: "go.mod"
34+
cache: false
35+
36+
- name: Lint
37+
uses: golangci/golangci-lint-action@v6
38+
with:
39+
args: --build-tags client -p bugs -p unused --timeout=3m
40+
41+
- name: Make tag
42+
run: |
43+
[ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true
44+
[ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true
45+
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true
46+
47+
- name: Build and push image
48+
uses: docker/build-push-action@v6
49+
with:
50+
context: .
51+
push: true
52+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }}

0 commit comments

Comments
 (0)