.gitea/workflows/build.yml aktualisiert
This commit is contained in:
+42
-26
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
name: Build container image
|
name: Build container image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -25,32 +26,33 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
id-token: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Prepare environment
|
- name: Prepare environment
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
REGISTRY_HOST=$(echo "${{ github.server_url }}" | awk -F/ '{print $3}')
|
REGISTRY_HOST=$(echo "${{ github.server_url }}" | awk -F/ '{print $3}')
|
||||||
OWNER_LOWER="${{ github.repository_owner }}"
|
OWNER_LOWER="${{ github.repository_owner }}"
|
||||||
NAME_LOWER="${{ env.IMAGE_NAME }}"
|
NAME_LOWER="${{ env.IMAGE_NAME }}"
|
||||||
|
|
||||||
echo "REGISTRY_HOST=${REGISTRY_HOST}" >> ${GITHUB_ENV}
|
echo "REGISTRY_HOST=${REGISTRY_HOST}" >> "${GITHUB_ENV}"
|
||||||
echo "IMAGE_REGISTRY=${REGISTRY_HOST}/${OWNER_LOWER,,}" >> ${GITHUB_ENV}
|
echo "IMAGE_REGISTRY=${REGISTRY_HOST}/${OWNER_LOWER,,}" >> "${GITHUB_ENV}"
|
||||||
echo "IMAGE_NAME=${NAME_LOWER,,}" >> ${GITHUB_ENV}
|
echo "IMAGE_NAME=${NAME_LOWER,,}" >> "${GITHUB_ENV}"
|
||||||
|
|
||||||
# Aktuelles Tagesdatum direkt von der Runner-VM beziehen (UTC)
|
echo "DATE_TAG=$(date -u +'%Y%m%d')" >> "${GITHUB_ENV}"
|
||||||
echo "DATE_TAG=$(date -u +'%Y%m%d')" >> ${GITHUB_ENV}
|
echo "BUILD_DATE_ISO=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
|
||||||
echo "BUILD_DATE_ISO=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV}
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v7.0.1
|
uses: actions/checkout@v7.0.1
|
||||||
|
|
||||||
# Generiert die auth.json dynamisch im configs/ Ordner aus Template & Secret
|
|
||||||
- name: Prepare Registry Auth File
|
- name: Prepare Registry Auth File
|
||||||
env:
|
env:
|
||||||
AUTH_BASE64: ${{ secrets.READONLY_AUTH_BASE64 }}
|
AUTH_BASE64: ${{ secrets.READONLY_AUTH_BASE64 }}
|
||||||
run: |
|
run: |
|
||||||
sed "s|READONLY_TOKEN_PLACEHOLDER|${AUTH_BASE64}|g" configs/auth.json.template > configs/auth.json
|
set -euo pipefail
|
||||||
|
sed "s|READONLY_TOKEN_PLACEHOLDER|${AUTH_BASE64}|g" \
|
||||||
|
configs/auth.json.template > configs/auth.json
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4.3.0
|
uses: docker/setup-buildx-action@v4.3.0
|
||||||
@@ -86,26 +88,20 @@ jobs:
|
|||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.REGISTRY }}
|
password: ${{ secrets.REGISTRY }}
|
||||||
|
|
||||||
- name: Build and Push Image (Docker Buildx)
|
- name: Build and Push Image
|
||||||
uses: docker/build-push-action@v7.3.0
|
|
||||||
id: build_image
|
id: build_image
|
||||||
|
uses: docker/build-push-action@v7.3.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Containerfile
|
file: ./Containerfile
|
||||||
|
platforms: linux/amd64
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.metadata.outputs.tags }}
|
tags: ${{ steps.metadata.outputs.tags }}
|
||||||
labels: ${{ steps.metadata.outputs.labels }}
|
labels: ${{ steps.metadata.outputs.labels }}
|
||||||
oci-mediatypes: true
|
oci-mediatypes: true
|
||||||
compression: zstd
|
compression: zstd
|
||||||
# Aktiviert die Chunk-Map für zstd:chunked Range-Requests
|
provenance: false
|
||||||
build-args: |
|
sbom: false
|
||||||
BUILDKIT_OCI_MEDIATYPE=true
|
|
||||||
output: type=registry,push=${{ github.event_name != 'pull_request' }},oci-mediatypes=true,compression=zstd,compression-args=binary-path=/usr/bin/go-zstd-chunked
|
|
||||||
|
|
||||||
- name: Install envsubst dependencies
|
|
||||||
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
|
||||||
run: |
|
|
||||||
sudo apt-get update && sudo apt-get install -y gettext
|
|
||||||
|
|
||||||
- name: Install Cosign
|
- name: Install Cosign
|
||||||
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
||||||
@@ -117,21 +113,41 @@ jobs:
|
|||||||
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
|
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
|
||||||
COSIGN_PASSWORD: ""
|
COSIGN_PASSWORD: ""
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.REGISTRY }}" | cosign login "${{ env.REGISTRY_HOST }}" -u "${{ github.repository_owner }}" --password-stdin
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "${{ secrets.REGISTRY }}" | cosign login \
|
||||||
|
"${{ env.REGISTRY_HOST }}" \
|
||||||
|
-u "${{ github.repository_owner }}" \
|
||||||
|
--password-stdin
|
||||||
|
|
||||||
|
IMAGE="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||||
|
DIGEST="${{ steps.build_image.outputs.digest }}"
|
||||||
|
|
||||||
|
test -n "${DIGEST}"
|
||||||
|
|
||||||
# Signiere den Tag (Manifest List / Index) rekursiv
|
|
||||||
cosign sign -y \
|
cosign sign -y \
|
||||||
--key env://COSIGN_PRIVATE_KEY \
|
--key env://COSIGN_PRIVATE_KEY \
|
||||||
--recursive \
|
|
||||||
--use-signing-config=false \
|
--use-signing-config=false \
|
||||||
--new-bundle-format=false \
|
--new-bundle-format=false \
|
||||||
--registry-referrers-mode=legacy \
|
--registry-referrers-mode=legacy \
|
||||||
"${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}"
|
"${IMAGE}@${DIGEST}"
|
||||||
|
|
||||||
|
- name: Verify container image
|
||||||
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
IMAGE="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||||
|
DIGEST="${{ steps.build_image.outputs.digest }}"
|
||||||
|
|
||||||
|
test -f configs/cosign.pub
|
||||||
|
|
||||||
|
cosign verify \
|
||||||
|
--key configs/cosign.pub \
|
||||||
|
"${IMAGE}@${DIGEST}"
|
||||||
|
|
||||||
- name: Post-Build Cleanup
|
- name: Post-Build Cleanup
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
echo "Lösche erzeugte Auth-Datei..."
|
|
||||||
rm -f configs/auth.json
|
rm -f configs/auth.json
|
||||||
echo "Leere Buildx-internen Cache..."
|
|
||||||
docker buildx prune -a -f || true
|
docker buildx prune -a -f || true
|
||||||
Reference in New Issue
Block a user