Files
anchorhost-backend/.gitea/workflows/docker.yml
T
wfalkowski c177d7981d
Build and publish Docker image / build-and-publish (push) Successful in 2m45s
Refactor backend and add registry build workflow
2026-10-20 16:44:49 +00:00

50 lines
1.3 KiB
YAML

name: Build and publish Docker image
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Log in to Gitea Container Registry
env:
REGISTRY_USERNAME: ${{ gitea.actor }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
printf '%s' "$REGISTRY_TOKEN" |
docker login git.anchorhost.eu --username "$REGISTRY_USERNAME" --password-stdin
- name: Build and tag image
env:
COMMIT_SHA: ${{ gitea.sha }}
DOCKER_IMAGE: git.anchorhost.eu/anchorhost.eu/anchorhost-backend
run: |
docker build \
--label "org.opencontainers.image.revision=$COMMIT_SHA" \
--tag "$DOCKER_IMAGE:backend" \
--tag "$DOCKER_IMAGE:main-${COMMIT_SHA:0:12}" \
.
- name: Push image
env:
COMMIT_SHA: ${{ gitea.sha }}
DOCKER_IMAGE: git.anchorhost.eu/anchorhost.eu/anchorhost-backend
run: |
docker push "$DOCKER_IMAGE:backend"
docker push "$DOCKER_IMAGE:main-${COMMIT_SHA:0:12}"
- name: Log out from Gitea Container Registry
if: always()
run: docker logout