Skip to content

Commit 4f5d5e3

Browse files
committed
ci: refactor publish action
1 parent de35ddd commit 4f5d5e3

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

.github/workflows/publish.yaml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
tags:
55
- v*
66

7+
permissions:
8+
contents: read
9+
packages: write
10+
711
jobs:
812
publish:
913
runs-on: ubuntu-latest
@@ -13,12 +17,18 @@ jobs:
1317
with:
1418
go-version: "~1.24"
1519
- name: build
16-
run: |
17-
go build .
18-
- name: release
19-
run: |
20-
echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.GHCR_USER }}" --password-stdin
21-
docker build . --tag ghcr.io/${{github.repository}}:${GITHUB_REF#refs/tags/}
22-
docker tag ghcr.io/${{github.repository}}:${GITHUB_REF#refs/tags/} ghcr.io/${{github.repository}}:latest
23-
docker push ghcr.io/${{github.repository}}:${GITHUB_REF#refs/tags/}
24-
docker push ghcr.io/${{github.repository}}:latest
20+
run: go build -v .
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Build and push Docker image
28+
uses: docker/build-push-action@v5
29+
with:
30+
context: .
31+
push: true
32+
tags: |
33+
ghcr.io/${{ github.repository }}:${GITHUB_REF#refs/tags/}
34+
ghcr.io/${{ github.repository }}:latest

0 commit comments

Comments
 (0)