ikurotime / gitgud

public
main / .github/workflows/deploy.yml
1.5 KB · YAML Raw
 1name: Build and Push Docker Image
 2
 3on:
 4  push:
 5    branches: ["main"]
 6  workflow_dispatch:
 7
 8jobs:
 9  build-and-push:
10    runs-on: ubuntu-latest
11    permissions:
12      contents: read
13      packages: write
14
15    steps:
16      - name: Checkout repository
17        uses: actions/checkout@v4
18
19      - name: Log in to GitHub Container Registry
20        uses: docker/login-action@v3
21        with:
22          registry: ghcr.io
23          username: ${{ github.actor }}
24          password: ${{ secrets.GITHUB_TOKEN }}
25
26      - name: Set up Docker Buildx
27        uses: docker/setup-buildx-action@v3
28
29      - name: Extract metadata (for tags)
30        id: meta
31        uses: docker/metadata-action@v5
32        with:
33          images: ghcr.io/${{ github.repository }}
34          tags: |
35            type=raw,value=latest
36            type=raw,value=main-${{ github.sha }}
37          labels: |
38            org.opencontainers.image.revision=${{ github.sha }}
39
40      - name: Build and push Docker image
41        uses: docker/build-push-action@v5
42        with:
43          context: .
44          file: ./Dockerfile
45          push: true
46          tags: ${{ steps.meta.outputs.tags }}
47          labels: ${{ steps.meta.outputs.labels }}
48          platforms: linux/amd64
49          cache-from: type=gha
50          cache-to: type=gha,mode=max
51
52      - name: Trigger Dokploy deployment
53        if: success()
54        run: |
55          curl -X POST "${{ secrets.DOKPLOY_WEBHOOK_URL }}" \
56            -H "Content-Type: application/json" \
57            -w "\nHTTP Status: %{http_code}\n" \
58            --fail-with-body