# name: Create and publish a Docker image on: push: branches: ["main"] release: types: [published] env: REGISTRY: gitea.bruyant.xyz IMAGE_NAME: ${{ gitea.repository }} jobs: build-and-push-image: runs-on: ubuntu-latest container: image: catthehacker/ubuntu:act-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Create Kubeconfig run: | mkdir $HOME/.kube echo "${{ secrets.BUILDX_KUBECONFIG }}" > $HOME/.kube/config - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver: kubernetes driver-opts: | namespace=buildx serviceaccount=buildx qemu.install=true - name: Log in to the Container registry uses: docker/login-action@7ca345011ac4304463197fac0e56eab1bc7e6af0 with: registry: ${{ env.REGISTRY }} username: ${{ gitea.actor }} password: ${{ secrets.PACKAGE_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@44d81d6d2a5a935e1a481942268529623f1f5ccd with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=semver,pattern={{version}} type=ref,event=branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - name: Build and push Docker image uses: docker/build-push-action@8796455d3250bab0b8ea17630e10645c29a1249a with: context: . push: true tags: | ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}