Add optimized Gitea CI/CD workflows for Docker builds
Some checks failed
Auto Build and Push Docker Image / build (push) Failing after 1m17s
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:
63
.gitea/workflows/docker-autobuild.yaml
Normal file
63
.gitea/workflows/docker-autobuild.yaml
Normal 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
|
||||
Reference in New Issue
Block a user