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