Add .gitea/workflows/image-publish.yml

This commit is contained in:
2026-07-05 18:51:45 +00:00
parent 183f9d5fec
commit 2a7187cd8a

View File

@@ -0,0 +1,56 @@
name: Build and Push Docker Image
on:
push:
branches:
- master
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate tags
id: vars
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: git.harryesses.com
username: ${{ gitea.repository_owner }}
password: ${{ secrets.PACKAGE_TOKEN }}
- name: Set image name
run: |
IMAGE_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
- name: Build Docker image
run: |
docker build \
-t git.harryesses.com/${IMAGE_NAME}:latest \
-t git.harryesses.com/${IMAGE_NAME}:${SHORT_SHA} \
-t git.harryesses.com/${IMAGE_NAME}:${BUILD_DATE} \
.
- name: Push latest tag
run: |
docker push git.harryesses.com/${IMAGE_NAME}:latest
- name: Push commit hash tag
run: |
docker push git.harryesses.com/${IMAGE_NAME}:${SHORT_SHA}
- name: Push datetime tag
run: |
docker push git.harryesses.com/${IMAGE_NAME}:${BUILD_DATE}