Skip to content

Commit a172643

Browse files
Add more tags to the container image and use suffise base because this is the base image
Signed-off-by: Nicolas-Peiffer <[email protected]>
1 parent bb5f489 commit a172643

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

.github/workflows/container-build.yaml .github/workflows/base-container-build.yaml

+29-4
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,47 @@ on:
2020
# - CONTAINERFILE_NAME is name and location of the Containerfile.
2121
env:
2222
KANIKO_BUILD_CONTEXT: "${{ github.workspace }}"
23-
CONTAINERFILE_NAME: "${{ github.workspace }}/Containerfile.goreleaser-ko-cosign-trivy-syft-x86-arm64-root-usr"
23+
CONTAINERFILE_NAME: "${{ github.workspace }}/Containerfile.goreleaser-ko-cosign-trivy-syft-x86-arm64-root-usr.base"
2424

2525
jobs:
2626
build:
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@v4
30-
- uses: docker/metadata-action@v5
29+
- name: Checkout source code
30+
uses: actions/checkout@v4
31+
32+
- name: Extract Versions from Containerfile
33+
id: extract
34+
run: |
35+
# Extract values from the Containerfile
36+
GOLANG_VERSION=$(grep -m1 'ARG GOLANG_VERSION=' $CONTAINERFILE_NAME | cut -d'=' -f2)
37+
echo "GOLANG_VERSION=${GOLANG_VERSION}" >> $GITHUB_ENV
38+
GORELEASER_VERSION=$(grep -m1 'ARG GORELEASER_VERSION=' $CONTAINERFILE_NAME | cut -d'=' -f2)
39+
echo "GORELEASER_VERSION=${GORELEASER_VERSION}" >> $GITHUB_ENV
40+
env:
41+
golang_version: ${{ env.GOLANG_VERSION }}
42+
goreleaser_version: ${{ env.GORELEASER_VERSION }}
43+
44+
- name: Container metadata and tags
45+
uses: docker/metadata-action@v5
3146
id: metadata
3247
with:
33-
images: ghcr.io/${{ github.repository }}
48+
images: ghcr.io/${{ github.repository }}-base
49+
tags: |
50+
type=ref,event=branch
51+
type=raw,value=golang-${{ steps.extract.outputs.golang_version }}
52+
type=raw,value=goreleaser-${{ steps.extract.outputs.goreleaser_version }}
53+
# minimal (short sha)
54+
type=sha
55+
# full length sha
56+
type=sha,format=long
57+
3458
- uses: docker/login-action@v3
3559
with:
3660
registry: ghcr.io
3761
username: ${{ github.actor }}
3862
password: ${{ secrets.GITHUB_TOKEN }}
63+
3964
- uses: int128/kaniko-action@v1
4065
with:
4166
push: true

0 commit comments

Comments
 (0)