Update build-deploy.yaml
Some checks failed
Build and Deploy / build (push) Failing after 3m7s
Build and Deploy / Deploy to target (push) Has been skipped

This commit is contained in:
Lorenzo Venerandi
2026-03-20 14:34:22 +01:00
committed by GitHub
parent ce50ff8ac7
commit b62944ea3a

View File

@@ -1,62 +1,52 @@
name: Build and Deploy name: Build and Deploy
on: on:
push: push:
branches: [main] branches: [main]
pull_request: pull_request:
branches: [main] branches: [main]
workflow_dispatch:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
image-tags: ${{ steps.meta.outputs.tags }} image-tags: ${{ steps.meta.outputs.tags }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry - name: Log in to Gitea Container Registry
if: github.event_name == 'push' if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ vars.PACKAGES_REGISTRY }} registry: ${{ vars.PACKAGES_REGISTRY }}
username: ${{ secrets.USERNAME }} username: ${{ gitea.actor }}
password: ${{ secrets.TOKEN }} password: ${{ gitea.token }}
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: ${{ vars.PACKAGES_REGISTRY }}/${{ gitea.repository }} images: ${{ vars.PACKAGES_REGISTRY }}/${{ gitea.repository }}
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name == 'push' }} push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
deploy: deploy:
name: Deploy to target name: Deploy to target
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name == 'push' if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps: steps:
- name: Call deploy endpoint - name: Call deploy endpoint
run: | run: |
# Verifica che le variabili/secret siano impostati
if [ -z "${{ vars.DEPLOY_URL }}" ] || [ -z "${{ secrets.DEPLOY_USERNAME }}" ] || [ -z "${{ secrets.DEPLOY_PASSWORD }}" ]; then if [ -z "${{ vars.DEPLOY_URL }}" ] || [ -z "${{ secrets.DEPLOY_USERNAME }}" ] || [ -z "${{ secrets.DEPLOY_PASSWORD }}" ]; then
echo "DEPLOY_URL, DEPLOY_USERNAME or DEPLOY_PASSWORD not set; skipping deploy step." echo "DEPLOY_URL, DEPLOY_USERNAME or DEPLOY_PASSWORD not set; skipping deploy step."
exit 0 exit 0
fi fi
echo "Triggering deploy endpoint..." echo "Triggering deploy endpoint..."
# curl --fail ritorna exit code != 0 se lo status HTTP non è 2xx
curl --fail -s -X POST \ curl --fail -s -X POST \
--user "${{ secrets.DEPLOY_USERNAME }}:${{ secrets.DEPLOY_PASSWORD }}" \ --user "${{ secrets.DEPLOY_USERNAME }}:${{ secrets.DEPLOY_PASSWORD }}" \
"${{ vars.DEPLOY_URL }}" "${{ vars.DEPLOY_URL }}"