build-private-images-ghcr.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. name: Build Private Images GHCR
  2. on:
  3. push:
  4. branches: [master, stable]
  5. tags: ['r*']
  6. pull_request:
  7. types: [synchronize, labeled]
  8. concurrency:
  9. group: ${{ github.workflow }}-${{ github.ref }}
  10. cancel-in-progress: true
  11. jobs:
  12. build:
  13. if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'deploy-to-staging') }}
  14. runs-on: buildjet-16vcpu-ubuntu-2204
  15. permissions:
  16. contents: read
  17. packages: write
  18. steps:
  19. - name: Docker meta
  20. id: meta
  21. uses: docker/metadata-action@v5.0.0
  22. with:
  23. images: ghcr.io/plausible/analytics/ee
  24. tags: |
  25. type=ref,event=pr
  26. type=ref,event=branch
  27. type=ref,event=tag
  28. - name: Set up Docker Buildx
  29. uses: docker/setup-buildx-action@v3
  30. - name: Login to GitHub Container Registry
  31. uses: docker/login-action@v3
  32. with:
  33. registry: ghcr.io
  34. username: ${{ github.actor }}
  35. password: ${{ secrets.GITHUB_TOKEN }}
  36. - name: Build and push
  37. id: docker_build
  38. uses: docker/build-push-action@v5
  39. with:
  40. push: true
  41. tags: ${{ steps.meta.outputs.tags }}
  42. labels: ${{ steps.meta.outputs.labels }}
  43. cache-from: type=gha
  44. cache-to: type=gha,mode=max
  45. build-args: |
  46. MIX_ENV=prod
  47. BUILD_METADATA=${{ steps.meta.outputs.json }}
  48. - name: Image digest
  49. run: echo ${{ steps.docker_build.outputs.digest }}
  50. - name: Notify team on failure
  51. if: ${{ failure() }}
  52. uses: fjogeleit/http-request-action@v1
  53. with:
  54. url: ${{ secrets.BUILD_NOTIFICATION_URL }}
  55. method: 'POST'
  56. customHeaders: '{"Content-Type": "application/json"}'
  57. data: '{"content": "<a href=\"https://github.com/plausible/analytics/actions/workflows/build-private-images.yml\">Build failed</a>"}'