name: Build and deploy on: pull_request: push: branches: [main] workflow_dispatch: jobs: validate: name: Validate source runs-on: ubuntu-latest timeout-minutes: 15 steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - name: Run fast regression checks run: | python3 -m py_compile local/*.py deploy/*.py python3 -m unittest \ local.test_dependency_lock \ local.test_staging_readiness \ deploy.test_production_preflight \ local.test_pricing -v sh -n local/lock_dependencies.sh publish-and-deploy: name: Publish images and notify Portainer needs: validate if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main' runs-on: ubuntu-latest timeout-minutes: 45 steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - name: Sign in to the Gitea Container Registry env: REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} run: | test -n "$REGISTRY_USERNAME" test -n "$REGISTRY_TOKEN" echo "$REGISTRY_TOKEN" | docker login gitea.blyzer.com.br \ --username "$REGISTRY_USERNAME" --password-stdin - name: Build and publish API run: | image="gitea.blyzer.com.br/blyzer/dtf-api" docker build --pull --file deploy/Dockerfile.api \ --build-arg VCS_REF="${{ gitea.sha }}" \ --tag "$image:latest" --tag "$image:${{ gitea.sha }}" . docker push "$image:latest" docker push "$image:${{ gitea.sha }}" - name: Build and publish web run: | image="gitea.blyzer.com.br/blyzer/dtf-web" docker build --pull --file deploy/Dockerfile.web \ --build-arg VCS_REF="${{ gitea.sha }}" \ --tag "$image:latest" --tag "$image:${{ gitea.sha }}" . docker push "$image:latest" docker push "$image:${{ gitea.sha }}" - name: Trigger Portainer redeployment env: PORTAINER_WEBHOOK: ${{ secrets.PORTAINER_WEBHOOK }} run: | if [ -z "$PORTAINER_WEBHOOK" ]; then echo "PORTAINER_WEBHOOK is not configured; images were published but deployment was skipped." exit 0 fi curl --fail --silent --show-error --max-time 30 --request POST "$PORTAINER_WEBHOOK"