Optimize GitHub Actions workflow

- Remove heavy Python dependencies installation from CI
- Add basic syntax check instead of full dependency install
- Optimize Podman installation with quiet flags
- Add build cache with --layers flag
- Add 30-minute timeout to prevent hanging
- Use single build with tag instead of double build
- Improve overall workflow performance
This commit is contained in:
2025-09-25 17:40:26 -03:00
parent 071ffefef7
commit ed992e4c94

View File

@@ -15,6 +15,7 @@ env:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
@@ -25,19 +26,15 @@ jobs:
with:
python-version: '3.11'
- name: Install dependencies
- name: Run basic syntax check
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
python -c "import app.main; print('✅ App imports successfully')"
python -m py_compile app/main.py
echo "✅ Syntax check passed"
- name: Set up Podman
run: |
sudo apt-get update
sudo apt-get install -y podman buildah skopeo
sudo apt-get update -qq
sudo apt-get install -y -qq podman buildah skopeo
- name: Login to Docker Hub
run: |
@@ -45,9 +42,11 @@ jobs:
- name: Build and push image with Podman
run: |
# Build da imagem
podman build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} .
podman build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest .
# Build da imagem com cache
podman build --layers -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} .
# Tag como latest
podman tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# Push das imagens
podman push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}