Files
Mayacontigo/.github/workflows/release.yml
Anibal Angulo cccf0a4784 Update release workflow for new images
Update the release workflow to build and tag the new images. The images
are now tagged with the image name and the latest tag. The build cache
has been removed as it is not needed.
2025-11-25 06:13:15 +00:00

84 lines
2.7 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: 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.image }}:latest,${{ steps.meta.outputs.image }}:${{ github.sha }}
build-args: |
PACKAGE=${{ matrix.app }}
- 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