name: Build and Push Docker Image on: push: branches: ["main"] workflow_dispatch: jobs: build-and-push: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Extract metadata (for tags) id: meta uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} tags: | type=raw,value=latest type=raw,value=main-${{ github.sha }} labels: | org.opencontainers.image.revision=${{ github.sha }} - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64 cache-from: type=gha cache-to: type=gha,mode=max - name: Trigger Dokploy deployment if: success() run: | curl -X POST "${{ secrets.DOKPLOY_WEBHOOK_URL }}" \ -H "Content-Type: application/json" \ -w "\nHTTP Status: %{http_code}\n" \ --fail-with-body