Files
Mayacontigo/.github/workflows/release.yml
2025-11-25 05:54:58 +00:00

89 lines
2.9 KiB
YAML

name: Release - Build & Push Containers
on:
push:
branches:
- main
paths:
- 'apps/**'
- '.containers/python/Dockerfile'
- 'packages/**'
- 'pyproject.toml'
- 'uv.lock'
env:
REGISTRY: gitea.ia-innovacion.work
REGISTRY_PATH: innovacion/mayacontigo
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
changed-apps: ${{ steps.detect.outputs.changed-apps }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed apps
id: detect
run: |
# Get list of changed apps compared to previous commit
if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
# Initial push - build all apps
CHANGED_APPS=$(ls -d apps/*/ | sed 's|apps/||g' | sed 's|/||g' | jq -R -s -c 'split("\n")[:-1]')
else
# Compare with previous commit
CHANGED_APPS=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep '^apps/' | cut -d/ -f2 | sort -u | jq -R -s -c 'split("\n") | map(select(length > 0))')
fi
echo "changed-apps=$CHANGED_APPS" >> $GITHUB_OUTPUT
echo "Changed apps: $CHANGED_APPS"
build-and-push:
needs: detect-changes
if: needs.detect-changes.outputs.changed-apps != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
app: ${{ fromJson(needs.detect-changes.outputs.changed-apps) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GITEA_REGISTRY_USERNAME }}
password: ${{ secrets.GITEA_REGISTRY_PASSWORD }}
- name: Extract metadata
id: meta
run: |
IMAGE="${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}-${{ matrix.app }}"
echo "image=$IMAGE" >> $GITHUB_OUTPUT
echo "tags=$IMAGE:latest,$IMAGE:${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: .containers/python/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
PACKAGE=${{ matrix.app }}
cache-from: type=registry,ref=${{ steps.meta.outputs.image }}:buildcache
cache-to: type=registry,ref=${{ steps.meta.outputs.image }}:buildcache,mode=max
- name: Image summary
run: |
echo "### ✅ Built and pushed: ${{ matrix.app }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Image: ${{ steps.meta.outputs.image }}" >> $GITHUB_STEP_SUMMARY
echo "Tags: latest, ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY