|
| 1 | +name: Docker Build and Publish — API Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - "apps/api-docs/**" |
| 9 | + - "libs/flowdrop/api/**" |
| 10 | + - ".github/workflows/docker-publish-api-docs.yml" |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + IMAGE_NAME: flowdrop-io/flowdrop-api-docs |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-push: |
| 18 | + name: Build Docker image |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up Docker Buildx |
| 29 | + uses: docker/setup-buildx-action@v3 |
| 30 | + |
| 31 | + - name: Log in to Container Registry |
| 32 | + uses: docker/login-action@v3 |
| 33 | + with: |
| 34 | + registry: ${{ env.REGISTRY }} |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Extract image metadata |
| 39 | + id: meta |
| 40 | + uses: docker/metadata-action@v5 |
| 41 | + with: |
| 42 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 43 | + tags: | |
| 44 | + type=sha,prefix=sha- |
| 45 | + type=raw,value=latest,enable={{is_default_branch}} |
| 46 | +
|
| 47 | + - name: Build and push |
| 48 | + # Build context is repo root — Dockerfile copies libs/flowdrop/api/ at build time |
| 49 | + uses: docker/build-push-action@v6 |
| 50 | + with: |
| 51 | + context: . |
| 52 | + file: apps/api-docs/Dockerfile |
| 53 | + push: true |
| 54 | + tags: ${{ steps.meta.outputs.tags }} |
| 55 | + labels: ${{ steps.meta.outputs.labels }} |
| 56 | + cache-from: type=gha |
| 57 | + cache-to: type=gha,mode=max |
| 58 | + |
| 59 | + trigger-deploy: |
| 60 | + name: Trigger GitLab deployment |
| 61 | + needs: build-and-push |
| 62 | + runs-on: ubuntu-latest |
| 63 | + if: success() && github.ref == 'refs/heads/main' |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Trigger GitLab pipeline |
| 67 | + run: | |
| 68 | + curl --fail -X POST \ |
| 69 | + "https://source.factorial.io/api/v4/projects/1074/trigger/pipeline" \ |
| 70 | + -F "token=${{ secrets.GITLAB_TRIGGER_TOKEN }}" \ |
| 71 | + -F "ref=main" |
0 commit comments