Skip to content

Commit 0d2baa0

Browse files
committed
refactor: Github workflows
1 parent dac5a55 commit 0d2baa0

File tree

3 files changed

+48
-23
lines changed

3 files changed

+48
-23
lines changed

.github/workflows/docker-image.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,47 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
1214
- name: Get git tag
1315
id: tag
1416
uses: dawidd6/action-get-tag@v1
1517
with:
1618
strip_v: true
1719
- name: Set up QEMU
18-
uses: docker/setup-qemu-action@v2
20+
uses: docker/setup-qemu-action@v3
1921
- name: Set up Docker Buildx
20-
uses: docker/setup-buildx-action@v2
22+
uses: docker/setup-buildx-action@v3
2123
- name: Login to DockerHub
22-
uses: docker/login-action@v2.0.0
24+
uses: docker/login-action@v3
2325
with:
2426
username: ${{ secrets.DOCKER_USER }}
2527
password: ${{ secrets.DOCKER_PASSWORD }}
2628
- name: Login to GitHub Container Registry
27-
uses: docker/login-action@v2.0.0
29+
uses: docker/login-action@v3
2830
with:
2931
registry: ghcr.io
3032
username: ${{ github.repository_owner }}
31-
password: ${{ github.token }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Extract metadata
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: |
39+
timothyye/godns
40+
ghcr.io/timothyye/godns
41+
tags: |
42+
type=ref,event=tag
43+
type=raw,value=latest,enable={{is_default_branch}}
3244
- name: Build and push the docker image
33-
uses: docker/build-push-action@v3
45+
uses: docker/build-push-action@v6
3446
with:
47+
context: .
3548
platforms: linux/amd64,linux/arm64
3649
push: true
37-
tags: |
38-
timothyye/godns:latest
39-
timothyye/godns:${{steps.tag.outputs.tag}}
40-
ghcr.io/timothyye/godns:latest
41-
ghcr.io/timothyye/godns:${{steps.tag.outputs.tag}}
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
4252
build-args: |
4353
VERSION=v${{ steps.tag.outputs.tag }}
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max

.github/workflows/go.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ jobs:
55
name: Auto triggered CI job
66
runs-on: ubuntu-latest
77
steps:
8+
-
9+
name: Check out code into the Go module directory
10+
uses: actions/checkout@v4
811
-
912
name: Set up Node.js
1013
uses: actions/setup-node@v4
1114
with:
12-
node-version: 18
15+
node-version: 20
16+
cache: 'npm'
17+
cache-dependency-path: 'web/package-lock.json'
1318
-
14-
name: Set up Go 1.23
19+
name: Set up Go
1520
uses: actions/setup-go@v5
1621
with:
17-
go-version: 1.23.3
18-
id: go
19-
-
20-
name: Check out code into the Go module directory
21-
uses: actions/checkout@v4
22+
go-version: '1.23'
23+
cache: true
2224
-
2325
name: Build the frontend project
2426
run: |
@@ -29,9 +31,9 @@ jobs:
2931
go generate ./...
3032
-
3133
name: golangci-lint
32-
uses: golangci/golangci-lint-action@v3
34+
uses: golangci/golangci-lint-action@v6
3335
with:
3436
version: latest
3537
-
3638
name: Run unit tests
37-
run: go test ./...
39+
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...

.github/workflows/release.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,26 @@ jobs:
2121
name: Set up Node.js
2222
uses: actions/setup-node@v4
2323
with:
24-
node-version: 18
24+
node-version: 20
25+
cache: 'npm'
26+
cache-dependency-path: 'web/package-lock.json'
2527
-
2628
name: Set up Go
2729
uses: actions/setup-go@v5
2830
with:
29-
go-version: 1.23.3
31+
go-version: '1.23'
32+
cache: true
33+
-
34+
name: Build frontend
35+
run: |
36+
cd web
37+
npm ci
38+
npm run build
39+
cd ..
40+
go generate ./...
3041
-
3142
name: Run GoReleaser
32-
uses: goreleaser/goreleaser-action@v4
43+
uses: goreleaser/goreleaser-action@v6
3344
with:
3445
version: latest
3546
args: release --clean

0 commit comments

Comments
 (0)