|
| 1 | +name: Build and Push Meridian Docker Image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - "apps/meridian/**" |
| 9 | + - "packages/**" |
| 10 | + - ".github/workflows/meridian-docker.yml" |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +env: |
| 14 | + REGISTRY: ghcr.io |
| 15 | + IMAGE_NAME: ${{ github.repository_owner }}/meridian |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-and-push: |
| 19 | + runs-on: blacksmith-8vcpu-ubuntu-2404 |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v6 |
| 27 | + |
| 28 | + - name: Set up Docker Buildx |
| 29 | + uses: docker/setup-buildx-action@v3 |
| 30 | + |
| 31 | + - name: Log in to GitHub Container Registry |
| 32 | + uses: docker/login-action@v4 |
| 33 | + with: |
| 34 | + registry: ${{ env.REGISTRY }} |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Extract metadata for Docker |
| 39 | + id: meta |
| 40 | + uses: docker/metadata-action@v6 |
| 41 | + with: |
| 42 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 43 | + tags: | |
| 44 | + type=ref,event=branch |
| 45 | + type=sha,prefix={{branch}}- |
| 46 | + type=raw,value=latest,enable={{is_default_branch}} |
| 47 | +
|
| 48 | + - name: Build and push Docker image |
| 49 | + uses: docker/build-push-action@v7 |
| 50 | + with: |
| 51 | + context: . |
| 52 | + file: ./apps/meridian/Dockerfile |
| 53 | + platforms: linux/amd64 |
| 54 | + push: true |
| 55 | + tags: ${{ steps.meta.outputs.tags }} |
| 56 | + labels: ${{ steps.meta.outputs.labels }} |
| 57 | + cache-from: type=gha |
| 58 | + cache-to: type=gha,mode=max |
| 59 | + |
| 60 | + - name: Delete old Docker images |
| 61 | + uses: actions/delete-package-versions@v5 |
| 62 | + with: |
| 63 | + package-name: meridian |
| 64 | + package-type: container |
| 65 | + min-versions-to-keep: 2 |
| 66 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Trigger Dokploy Deployment |
| 69 | + run: | |
| 70 | + curl -X POST \ |
| 71 | + '${{ secrets.DOKPLOY_DOMAIN }}/api/application.deploy' \ |
| 72 | + -H 'accept: application/json' \ |
| 73 | + -H 'x-api-key: ${{ secrets.DOKPLOY_API_KEY }}' \ |
| 74 | + -H 'Content-Type: application/json' \ |
| 75 | + -d '{"applicationId": "${{ secrets.MERIDIAN_APPLICATION_ID }}"}' |
0 commit comments