Skip to content

initial

initial #6

Workflow file for this run

name: Release
on:
push:
branches:
- main
permissions:
contents: read
packages: write
id-token: write
jobs:
ci:
uses: ./.github/workflows/ci.yml
secrets: inherit
build-and-publish:
name: Build, Sign and Publish
needs: ci
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install Cosign
uses: sigstore/cosign-installer@v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker registry
uses: docker/login-action@v3
with:
registry: dhi.io
username: ${{ secrets.DHI_USERNAME }}
password: ${{ secrets.DHI_TOKEN }}
- name: Log in to GitHub registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=long
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Sign the published Docker image
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}
cleanup:
name: Cleanup Untagged Images
needs: build-and-publish
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Delete untagged images
uses: actions/delete-package-versions@v5
with:
package-name: ${{ github.event.repository.name }}
package-type: "container"
package-origin: "repository"
min-versions-to-keep: 0
delete-only-untagged-versions: "true"