From a6a9b9473317cb8925a2bb82f62b952ad4305557 Mon Sep 17 00:00:00 2001 From: Lorenzo Venerandi Date: Tue, 14 Oct 2025 11:40:27 +0200 Subject: [PATCH] gitea action --- .gitea/workflows/build-deploy.yaml | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .gitea/workflows/build-deploy.yaml diff --git a/.gitea/workflows/build-deploy.yaml b/.gitea/workflows/build-deploy.yaml new file mode 100644 index 0000000..04756eb --- /dev/null +++ b/.gitea/workflows/build-deploy.yaml @@ -0,0 +1,62 @@ +name: Build and Deploy + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + outputs: + image-tags: ${{ steps.meta.outputs.tags }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea Container Registry + if: github.event_name == 'push' + uses: docker/login-action@v3 + with: + registry: ${{ vars.PACKAGES_REGISTRY }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ vars.PACKAGES_REGISTRY }}/${{ gitea.repository }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name == 'push' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + deploy: + name: Deploy to target + needs: build + runs-on: ubuntu-latest + if: github.event_name == 'push' + steps: + - name: Call deploy endpoint + run: | + # Verifica che le variabili/secret siano impostati + 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." + exit 0 + fi + + echo "Triggering deploy endpoint..." + # curl --fail ritorna exit code != 0 se lo status HTTP non รจ 2xx + curl --fail -s -X POST \ + --user "${{ secrets.DEPLOY_USERNAME }}:${{ secrets.DEPLOY_PASSWORD }}" \ + "${{ vars.DEPLOY_URL }}"