Skip to content

Commit b56d4b6

Browse files
committed
chore: update workflow
1 parent b5d735a commit b56d4b6

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

.github/workflows/build.yaml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ on:
77
pull_request:
88
branches:
99
- master
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
1013

1114
jobs:
1215
build:
1316
runs-on: ubuntu-latest
1417

18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
1524
steps:
1625
- name: Checkout code
1726
uses: actions/checkout@v2
@@ -39,5 +48,31 @@ jobs:
3948
- name: Package
4049
run: mvn package
4150

42-
- name: Docker
43-
run: docker build -t intellicode/kotlin-hello .
51+
- name: Log in to the Container registry
52+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
53+
with:
54+
registry: ${{ env.REGISTRY }}
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Extract metadata (tags, labels) for Docker
59+
id: meta
60+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
61+
with:
62+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
63+
64+
- name: Build and push Docker image
65+
id: push
66+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
67+
with:
68+
context: .
69+
push: true
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}
72+
73+
- name: Generate artifact attestation
74+
uses: actions/attest-build-provenance@v2
75+
with:
76+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
77+
subject-digest: ${{ steps.push.outputs.digest }}
78+
push-to-registry: true

0 commit comments

Comments
 (0)