52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
name: Build and publish Docker image
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: docker
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Resolve registry and image metadata
|
|
id: meta
|
|
run: |
|
|
host="${GITEA_SERVER_URL#*://}"
|
|
image="$host/${GITEA_REPOSITORY,,}"
|
|
echo "host=$host" >> "$GITHUB_OUTPUT"
|
|
echo "image=$image" >> "$GITHUB_OUTPUT"
|
|
if [ "$GITEA_REF_TYPE" = "tag" ]; then
|
|
echo "tag=$GITEA_REF_NAME" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "tag=latest" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
env:
|
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
|
GITEA_REF_TYPE: ${{ gitea.ref_type }}
|
|
GITEA_REF_NAME: ${{ gitea.ref_name }}
|
|
|
|
- name: Log in to the Gitea container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ steps.meta.outputs.host }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.tag }}
|
|
${{ steps.meta.outputs.image }}:${{ gitea.sha }}
|