- Remove obsolete deployment scripts outside /scripts folder - Remove redundant scripts inside /scripts folder - Remove release.sh as it won't be used in the process - Update GitHub Actions to use Quay.io instead of Docker Hub - Update registry references from andersonid to quay.io/rh_ee_anobre - Simplify deployment instructions to use deploy-complete.sh - Clean up codebase to maintain only essential scripts
128 lines
4.6 KiB
YAML
128 lines
4.6 KiB
YAML
name: Build and Push Image to Quay.io
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
tags: [ 'v*' ] # Build tags como v1.0.0
|
|
pull_request:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Custom tag for the image'
|
|
required: false
|
|
default: 'latest'
|
|
|
|
env:
|
|
IMAGE_NAME: resource-governance
|
|
REGISTRY: quay.io/rh_ee_anobre
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Run basic syntax check
|
|
run: |
|
|
python -m py_compile app/main.py
|
|
echo "✅ Syntax check passed"
|
|
|
|
- name: Set up Podman
|
|
run: |
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y -qq podman buildah skopeo
|
|
|
|
- name: Login to Quay.io
|
|
run: |
|
|
echo "${{ secrets.QUAY_TOKEN }}" | podman login quay.io -u ${{ secrets.QUAY_USERNAME }} --password-stdin
|
|
|
|
- name: Determine image tags
|
|
id: tags
|
|
run: |
|
|
# Determinar tags baseado no trigger
|
|
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == refs/tags/* ]]; then
|
|
# Tag release (ex: v1.0.0)
|
|
TAG="${{ github.ref_name }}"
|
|
LATEST_TAG="latest"
|
|
elif [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.tag }}" != "" ]]; then
|
|
# Manual dispatch com tag customizada
|
|
TAG="${{ inputs.tag }}"
|
|
LATEST_TAG="latest"
|
|
elif [[ "${{ github.ref }}" == refs/heads/main ]]; then
|
|
# Branch main
|
|
TAG="${{ github.sha }}"
|
|
LATEST_TAG="latest"
|
|
elif [[ "${{ github.ref }}" == refs/heads/develop ]]; then
|
|
# Branch develop
|
|
TAG="develop-${{ github.sha }}"
|
|
LATEST_TAG="develop"
|
|
else
|
|
# Pull request ou outros
|
|
TAG="${{ github.sha }}"
|
|
LATEST_TAG="pr-${{ github.sha }}"
|
|
fi
|
|
|
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
|
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
|
|
echo "image_tag=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$TAG" >> $GITHUB_OUTPUT
|
|
echo "latest_image_tag=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$LATEST_TAG" >> $GITHUB_OUTPUT
|
|
|
|
echo "🏷️ Tags determinadas:"
|
|
echo " Tag: $TAG"
|
|
echo " Latest: $LATEST_TAG"
|
|
echo " Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$TAG"
|
|
echo " Latest Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$LATEST_TAG"
|
|
|
|
- name: Build and push image
|
|
run: |
|
|
# Build da imagem com cache
|
|
echo "🔨 Building image: ${{ steps.tags.outputs.image_tag }}"
|
|
podman build --layers -t ${{ steps.tags.outputs.image_tag }} .
|
|
|
|
# Tag como latest (se aplicável)
|
|
if [[ "${{ steps.tags.outputs.latest_tag }}" != "pr-${{ github.sha }}" ]]; then
|
|
echo "🏷️ Tagging as latest: ${{ steps.tags.outputs.latest_image_tag }}"
|
|
podman tag ${{ steps.tags.outputs.image_tag }} ${{ steps.tags.outputs.latest_image_tag }}
|
|
fi
|
|
|
|
# Push das imagens
|
|
echo "📤 Pushing image: ${{ steps.tags.outputs.image_tag }}"
|
|
podman push ${{ steps.tags.outputs.image_tag }}
|
|
|
|
if [[ "${{ steps.tags.outputs.latest_tag }}" != "pr-${{ github.sha }}" ]]; then
|
|
echo "📤 Pushing latest: ${{ steps.tags.outputs.latest_image_tag }}"
|
|
podman push ${{ steps.tags.outputs.latest_image_tag }}
|
|
fi
|
|
|
|
- name: Output deployment info
|
|
run: |
|
|
echo "🚀 Image built and pushed successfully!"
|
|
echo "📦 Image: ${{ steps.tags.outputs.image_tag }}"
|
|
if [[ "${{ steps.tags.outputs.latest_tag }}" != "pr-${{ github.sha }}" ]]; then
|
|
echo "📦 Latest: ${{ steps.tags.outputs.latest_image_tag }}"
|
|
fi
|
|
echo ""
|
|
echo "🔧 To deploy to your OpenShift cluster:"
|
|
echo "1. Clone this repository"
|
|
echo "2. Run: ./scripts/deploy-complete.sh"
|
|
echo ""
|
|
echo "🐳 Quay.io: https://quay.io/repository/rh_ee_anobre/${{ env.IMAGE_NAME }}"
|
|
|
|
- name: Create GitHub Release (for tags)
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
echo "🏷️ Creating GitHub Release for ${{ github.ref_name }}"
|
|
gh release create ${{ github.ref_name }} \
|
|
--title "Release ${{ github.ref_name }}" \
|
|
--notes "OpenShift Resource Governance ${{ github.ref_name }}" \
|
|
--target main
|