Skip to content

Trigger release_automation build #1

Trigger release_automation build

Trigger release_automation build #1

name: Build Release Automation Docker Image
on:
workflow_dispatch:
inputs:
image_tag:
description: 'Docker image tag (default: latest)'
required: false
default: 'latest'
push_to_ghcr:
description: 'Push image to GHCR'
required: false
default: true
type: boolean
push:
branches:
- release/8.2
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/release-automation
jobs:
build-test-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ github.event.inputs.image_tag }}
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix={{branch}}-
- name: Build Docker image (without pushing)
uses: docker/build-push-action@v5
with:
context: ./release-automation
file: ./release-automation/docker/Dockerfile
push: false
tags: test-image:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
# Integration tests do need access to git repository
- name: Test the built image
run: |
# Start container and install dev dependencies for testing
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
--entrypoint /bin/bash \
test-image:latest \
-c "
cd release-automation
set -e
echo '=== Installing test dependencies ==='
pip install pytest pytest-cov
echo '=== Running tests ==='
pytest -v tests/
"
- name: Log in to Container Registry
if: ${{ github.event.inputs.push_to_ghcr == 'true' }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push image
if: ${{ github.event.inputs.push_to_ghcr == 'true' }}
run: |
# Tag the tested image with the proper tags
echo '${{ steps.meta.outputs.tags }}' | while read -r tag; do
docker tag test-image:latest "$tag"
docker push "$tag"
done
- name: Output image details
run: |
echo "## Docker Image Built Successfully! 🐳" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ **Tests passed**" >> $GITHUB_STEP_SUMMARY
echo "🏗️ **Production image built** (without dev dependencies)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo '${{ steps.meta.outputs.tags }}' | sed 's/^/- `/' | sed 's/$/`/' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ github.event.inputs.push_to_ghcr }}" == "true" ]]; then
echo "✅ **Image pushed to GHCR**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "To pull the image:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.image_tag }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
else
echo "ℹ️ **Image built locally only (not pushed)**" >> $GITHUB_STEP_SUMMARY
fi