From 31883c579b94b7c66399679045497a0bd66f3ec4 Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Wed, 6 May 2026 15:25:43 +0300 Subject: [PATCH] =?UTF-8?q?ci:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D1=83=20=D1=81=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=BE=D0=B9=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/gitea-push-docker.yml | 109 ++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/gitea-push-docker.yml b/.gitea/workflows/gitea-push-docker.yml index 65417ff..7da12c0 100644 --- a/.gitea/workflows/gitea-push-docker.yml +++ b/.gitea/workflows/gitea-push-docker.yml @@ -1,17 +1,48 @@ -name: Create and publish a Docker image +name: 🚀 Create and publish a Docker image on: push: - branches: ['main', 'staging'] + branches: ['main', 'dev'] env: - CONTEXT: ./backend + BACKEND_PATH: backend + # FRONTEND_PATH: frontend + SERVER_DOMAIN: ${{ gitea.server_url.replace('https://', '') }} jobs: - build-and-push-image: + detect-changes: runs-on: ubuntu-latest - name: Publish image + name: Detect changes in backend and frontend container: catthehacker/ubuntu:act-latest + outputs: + backend_changed: ${{ steps.backend-changed.outputs.backend }} + # frontend_changed: ${{ steps.frontend-changed.outputs.frontend }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check for backend changes + id: backend-changed + uses: dorny/paths-filter@v2 + with: + filters: | + backend: + - '${{ env.BACKEND_PATH }}/**' + + # - name: Check for frontend changes + # id: frontend-changed + # uses: dorny/paths-filter@v2 + # with: + # filters: | + # frontend: + # - '${{ env.FRONTEND_PATH }}/**' + + backend: + runs-on: ubuntu-latest + name: Build & publish backend image + container: catthehacker/ubuntu:act-latest + needs: [detect-changes] + if: ${{ needs.detect-changes.outputs.backend_changed == 'true' }} permissions: contents: read packages: write @@ -24,17 +55,69 @@ jobs: id: meta uses: https://github.com/docker/metadata-action@v4 with: - images: ${{ vars.SERVER_DOMAIN }}/${{ gitea.repository }} - - name: Build an image from Dockerfile - run: | - cd ${{ env.CONTEXT }} && - docker build -f UniVerse.Api/Dockerfile -t ${{ steps.meta.outputs.tags }} . + images: ${{ vars.SERVER_DOMAIN }}/${{ gitea.repository }}/backend + - name: Log in to the Container registry uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: registry: ${{ vars.SERVER_DOMAIN }} username: ${{ gitea.actor }} password: ${{ secrets.TOKEN }} - - name: Push - run: | - docker push '${{ steps.meta.outputs.tags }}' + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: ./${{ env.BACKEND_PATH }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # frontend: + # runs-on: ubuntu-latest + # name: Build & publish frontend image + # container: catthehacker/ubuntu:act-latest + # needs: [detect-changes] + # if: ${{ needs.detect-changes.outputs.frontend_changed == 'true' }} + # permissions: + # contents: read + # packages: write + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v3 + + # - name: Log in to the Container registry + # uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + # with: + # registry: ${{ vars.SERVER_DOMAIN }} + # username: ${{ gitea.actor }} + # password: ${{ secrets.TOKEN }} + + # - name: Extract metadata (tags, labels) for Docker + # id: meta + # uses: https://github.com/docker/metadata-action@v4 + # with: + # images: ${{ vars.SERVER_DOMAIN }}/${{ gitea.repository }}/frontend + + # - name: Build and push Docker image + # uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + # with: + # context: ./${{ env.FRONTEND_PATH }} + # push: true + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + + deploy: + runs-on: ubuntu-latest + # needs: [frontend, backend] + needs: [backend] + # always() - костыль для того, чтобы деплой выполнялся даже если один из билдов пропущен + if: github.ref == 'refs/heads/dev' && always() && (needs.backend.result == 'success' || needs.frontend.result == 'success') + name: Update stack on Portainer + steps: + - name: Deploy Stage + uses: fjogeleit/http-request-action@v1 + with: + url: ${{ secrets.PORTAINER_WEBHOOK_URL }} + method: 'POST' + ignoreSsl: true + timeout: 60000