|
5 | 5 | branches: ["main"]
|
6 | 6 | tags: ["v*.*.*"]
|
7 | 7 |
|
| 8 | +env: |
| 9 | + REGISTRY: ghcr.io |
| 10 | + IMAGE_NAME: ${{ github.repository }} |
| 11 | + |
8 | 12 | jobs:
|
9 |
| - build: |
| 13 | + run-tests: |
10 | 14 | runs-on: ubuntu-latest
|
11 | 15 | strategy:
|
12 | 16 | matrix:
|
@@ -35,11 +39,60 @@ jobs:
|
35 | 39 | - name: Lint with golangci-lint
|
36 | 40 | run: golangci-lint run ./...
|
37 | 41 |
|
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 |
40 | 92 |
|
41 |
| - - name: Upload test results |
42 |
| - uses: actions/upload-artifact@v4 |
| 93 | + - name: Generate artifact attestation |
| 94 | + uses: actions/attest-build-provenance@v2 |
43 | 95 | 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