changed build.yml after reworking Infrastructure
This commit is contained in:
@@ -30,7 +30,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Prepare environment
|
- name: Prepare environment
|
||||||
run: |
|
run: |
|
||||||
# Extrahiert die reine Domain/Host (inkl. Port, falls vorhanden) aus der Gitea-URL
|
|
||||||
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 }}"
|
||||||
@@ -61,7 +60,7 @@ jobs:
|
|||||||
id: metadata
|
id: metadata
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.IMAGE_REGISTRY }}/${{ github.repository }}
|
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=${{ env.IMAGE_TAG }}
|
type=raw,value=${{ env.IMAGE_TAG }}
|
||||||
type=raw,value=${{ env.IMAGE_TAG }}.{{date 'YYYYMMDD'}},enable=${{ env.IS_TEST_BUILD == 'false' }}
|
type=raw,value=${{ env.IMAGE_TAG }}.{{date 'YYYYMMDD'}},enable=${{ env.IS_TEST_BUILD == 'false' }}
|
||||||
@@ -80,11 +79,6 @@ jobs:
|
|||||||
containers.bootc=1
|
containers.bootc=1
|
||||||
ostree.bootable=1
|
ostree.bootable=1
|
||||||
|
|
||||||
- name: Install Skopeo
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y skopeo
|
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
- name: Login to Gitea Container Registry
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -93,46 +87,24 @@ jobs:
|
|||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.REGISTRY }}
|
password: ${{ secrets.REGISTRY }}
|
||||||
|
|
||||||
- name: Build Image Locally (as true OCI Archive)
|
- name: Build and Push Image (Native OCI via Buildx)
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
id: build_image
|
id: build_image
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Containerfile
|
file: ./Containerfile
|
||||||
push: false
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
# Wir schreiben ALLE Tags direkt in ein echtes OCI-Archiv auf die Platte
|
|
||||||
outputs: type=oci,dest=image.tar
|
|
||||||
tags: ${{ steps.metadata.outputs.tags }}
|
tags: ${{ steps.metadata.outputs.tags }}
|
||||||
labels: ${{ steps.metadata.outputs.labels }}
|
labels: ${{ steps.metadata.outputs.labels }}
|
||||||
|
|
||||||
- name: Push Image via Skopeo (All Tags)
|
- name: Install Skopeo (Required for Cosign Inspect)
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && env.IS_TEST_BUILD == 'false'
|
||||||
env:
|
|
||||||
GENERATED_TAGS: ${{ steps.metadata.outputs.tags }}
|
|
||||||
run: |
|
run: |
|
||||||
# Die mehrzeiligen Tags in ein Bash-Array umwandeln
|
sudo apt-get update
|
||||||
TAG_LIST=($GENERATED_TAGS)
|
sudo apt-get install -y skopeo
|
||||||
|
|
||||||
# Wir loopen über das OCI-Archiv. Skopeo findet dort jetzt JEDES Tag!
|
|
||||||
for tag in "${TAG_LIST[@]}"; do
|
|
||||||
echo "Pushing $tag as native OCI to Gitea..."
|
|
||||||
skopeo copy \
|
|
||||||
--format oci \
|
|
||||||
--dest-creds "${{ github.repository_owner }}:${{ secrets.REGISTRY }}" \
|
|
||||||
oci-archive:image.tar \
|
|
||||||
docker://$tag
|
|
||||||
done
|
|
||||||
|
|
||||||
# Sauber aufräumen
|
|
||||||
rm -f image.tar
|
|
||||||
|
|
||||||
- name: Install envsubst dependencies
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
run: |
|
|
||||||
sudo apt-get update && sudo apt-get install -y gettext
|
|
||||||
|
|
||||||
- name: Install Cosign
|
- name: Install Cosign
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && env.IS_TEST_BUILD == 'false'
|
||||||
uses: sigstore/cosign-installer@v4.1.2
|
uses: sigstore/cosign-installer@v4.1.2
|
||||||
|
|
||||||
- name: Sign container image
|
- name: Sign container image
|
||||||
@@ -154,22 +126,3 @@ jobs:
|
|||||||
--tlog-upload=false \
|
--tlog-upload=false \
|
||||||
--registry-referrers-mode=legacy \
|
--registry-referrers-mode=legacy \
|
||||||
"${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}@${DIGEST}"
|
"${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}@${DIGEST}"
|
||||||
|
|
||||||
- name: Post-Build Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
echo "Starting safe, server-friendly cleanup..."
|
|
||||||
|
|
||||||
# 1. Entfernt NUR echte verwaiste Zwischenschritte (<none>:<none>)
|
|
||||||
# Niemals getaggte Images (wie deine Registry oder fluffy-pancake)
|
|
||||||
docker system prune -f --volumes
|
|
||||||
|
|
||||||
# 2. Den BuildKit-Cache leeren (Das ist der Haupt-Speicherfresser bei Buildx)
|
|
||||||
docker builder prune -af
|
|
||||||
|
|
||||||
# 3. Temporäre Datei löschen
|
|
||||||
rm -f image.tar
|
|
||||||
|
|
||||||
echo "Cleanup complete. Your server storage is safe!"
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user