65 lines
1.8 KiB
YAML
65 lines
1.8 KiB
YAML
#
|
|
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@906ecf0fc0a80f9110f79d9e6c04b1080f4a2621
|
|
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@11be14d908760a0756f045980728ec5fb7880f74
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|