Add optimized Gitea CI/CD workflows for Docker builds
Some checks failed
Auto Build and Push Docker Image / build (push) Failing after 1m17s

Features:
- docker-autobuild.yaml: Automated builds on push to main/master
  - Path ignores for markdown/docs files
  - Docker Buildx with caching support
  - Automatic cleanup after builds

- docker-build.yaml: Manual builds with flexible options
  - Custom version tags
  - Additional tags support (e.g., stable,production)
  - Toggle latest tag
  - Docker Buildx with layer caching

Both workflows:
- Use registry credentials from Gitea secrets
- Support local registry at 192.168.88.201:5000
- Proper login/logout handling
- Optimized for sticker-bot project
This commit is contained in:
coding
2026-03-25 09:20:29 +00:00
parent f634b884ec
commit 0c78512445
2 changed files with 153 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
name: Auto Build and Push Docker Image
on:
push:
branches:
- main
- master
paths-ignore:
- '**.md'
- '.gitignore'
- 'data/**'
- '.env.example'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin 192.168.88.201:5000 || true
- name: Build and Push Docker Image
run: |
REGISTRY="192.168.88.201:5000"
IMAGE_NAME="${{ gitea.repository }}"
# Versionierung: v{run_number}-autobuild
VERSION="v${{ gitea.run_number }}-autobuild"
FULL_IMAGE_PATH="$REGISTRY/$IMAGE_NAME"
echo "========================================"
echo "Building Docker Image"
echo "Registry: $REGISTRY"
echo "Image: $IMAGE_NAME"
echo "Version: $VERSION"
echo "========================================"
# Build with cache
docker build \
--cache-from $FULL_IMAGE_PATH:latest \
-t $FULL_IMAGE_PATH:latest \
-t $FULL_IMAGE_PATH:$VERSION \
.
# Push images
docker push $FULL_IMAGE_PATH:latest
docker push $FULL_IMAGE_PATH:$VERSION
echo "✅ Successfully built and pushed:"
echo " - $FULL_IMAGE_PATH:latest"
echo " - $FULL_IMAGE_PATH:$VERSION"
- name: Cleanup
if: always()
run: |
docker logout 192.168.88.201:5000 || true
docker system prune -f || true