Skip to content

Commit 8c56a86

Browse files
committed
feat: build and push docker image
1 parent e2262e3 commit 8c56a86

File tree

1 file changed

+60
-7
lines changed

1 file changed

+60
-7
lines changed

.github/workflows/ci.yml

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ on:
55
branches: ["main"]
66
tags: ["v*.*.*"]
77

8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
812
jobs:
9-
build:
13+
run-tests:
1014
runs-on: ubuntu-latest
1115
strategy:
1216
matrix:
@@ -35,11 +39,60 @@ jobs:
3539
- name: Lint with golangci-lint
3640
run: golangci-lint run ./...
3741

38-
- name: Test with go
39-
run: go test ./... -json > TestResults-${{ matrix.go-version }}.json
42+
# - name: Test with go
43+
# run: go test ./... -json > TestResults-${{ matrix.go-version }}.json
44+
45+
# - name: Upload test results
46+
# uses: actions/upload-artifact@v4
47+
# with:
48+
# name: go-results-${{ matrix.go-version }}
49+
# path: TestResults-${{ matrix.go-version }}.json
50+
51+
build-and-push-image:
52+
runs-on: ubuntu-latest
53+
needs: run-tests
54+
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
59+
- name: Extract metadata (tags, labels) for Docker
60+
id: meta
61+
uses: docker/metadata-action@v5
62+
with:
63+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
64+
65+
- name: Log in to DockerHub
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ${{ env.REGISTRY }}
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.DOCKERHUB_TOKEN }}
71+
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
75+
- name: Build and push
76+
uses: docker/build-push-action@v6
77+
with:
78+
context: .
79+
no-cache: true
80+
push: ${{ github.event_name != 'pull_request' }}
81+
tags: ${{ steps.meta.outputs.tags }}
82+
labels: ${{ steps.meta.outputs.labels }}
83+
84+
- name: Update DockerHub Description
85+
uses: peter-evans/dockerhub-description@v4
86+
with:
87+
username: ${{ github.actor }}
88+
password: ${{ secrets.DOCKERHUB_TOKEN }}
89+
repository: ${{ github.repository }}
90+
short-description: ${{ github.event.repository.description }}
91+
enable-url-completion: true
4092

41-
- name: Upload test results
42-
uses: actions/upload-artifact@v4
93+
- name: Generate artifact attestation
94+
uses: actions/attest-build-provenance@v2
4395
with:
44-
name: go-results-${{ matrix.go-version }}
45-
path: TestResults-${{ matrix.go-version }}.json
96+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
97+
subject-digest: ${{ steps.push.outputs.digest }}
98+
push-to-registry: true

0 commit comments

Comments
 (0)