Skip to content

Commit f4d4b0d

Browse files
committed
Added action for test, build and publish
1 parent 8a82440 commit f4d4b0d

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: '1.25'
24+
25+
- name: Download Go modules
26+
run: go mod download
27+
28+
- name: Run tests
29+
run: go test -v -race -coverprofile=coverage.out ./...
30+
31+
- name: Check test coverage
32+
run: go tool cover -func=coverage.out
33+
34+
build-and-publish:
35+
needs: test
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
43+
44+
- name: Log in to GitHub Container Registry
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ghcr.io
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Extract metadata
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ghcr.io/${{ github.repository_owner }}/lynx
56+
tags: |
57+
type=semver,pattern={{version}}
58+
type=semver,pattern={{major}}.{{minor}}
59+
type=ref,event=branch
60+
type=sha
61+
62+
- name: Build and push
63+
uses: docker/build-push-action@v5
64+
with:
65+
context: .
66+
push: true
67+
platforms: linux/amd64,linux/arm64
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
cache-from: type=gha
71+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)