-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (43 loc) · 1.63 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Create and publish Docker images
on:
push:
branches: ['main']
env:
REGISTRY: ghcr.io
IMAGE_NAMES: debian ubuntu
jobs:
build-and-push-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker images
run: |
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
for IMAGE_NAME in ${{ env.IMAGE_NAMES }}; do
echo "Building and pushing $IMAGE_NAME"
docker build -t ${{ env.REGISTRY }}/${REPO_NAME}:$IMAGE_NAME images/$IMAGE_NAME
docker push ${{ env.REGISTRY }}/${REPO_NAME}:$IMAGE_NAME
done
- name: Generate artifact attestations for Docker images
run: |
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
for IMAGE_NAME in ${{ env.IMAGE_NAMES }}; do
echo "Generating attestation for $IMAGE_NAME"
IMAGE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ env.REGISTRY }}/${REPO_NAME}:$IMAGE_NAME)
echo "Digest: $IMAGE_DIGEST"
gh actions upload-artifact $IMAGE_NAME-attestation --path $IMAGE_DIGEST
done