docker-dev.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: "[Build] Dev Image"
  2. on:
  3. workflow_dispatch:
  4. env:
  5. REGISTRY: ghcr.io
  6. IMAGE_NAME: ${{ github.repository }}
  7. jobs:
  8. build-and-push:
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: read
  12. packages: write
  13. steps:
  14. - name: Checkout repository
  15. uses: actions/checkout@v4
  16. - name: Set up Docker Buildx
  17. uses: docker/setup-buildx-action@v3
  18. - name: Log in to GitHub Container Registry
  19. uses: docker/login-action@v3
  20. with:
  21. registry: ${{ env.REGISTRY }}
  22. username: ${{ github.actor }}
  23. password: ${{ secrets.GITHUB_TOKEN }}
  24. - name: Get short commit SHA
  25. id: sha
  26. run: echo "short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
  27. - name: Extract metadata (tags, labels)
  28. id: meta
  29. uses: docker/metadata-action@v5
  30. with:
  31. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  32. tags: |
  33. type=raw,value=dev-${{ steps.sha.outputs.short }}
  34. # A short hash of the server action key, so a new key rebuilds Next
  35. # instead of reusing a cached build (see the Dockerfile).
  36. - name: Fingerprint the server action key
  37. id: actions_key
  38. env:
  39. KEY: ${{ secrets.NEXT_SERVER_ACTIONS_BUILD_KEY }}
  40. run: echo "id=$(printf '%s' "$KEY" | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT"
  41. - name: Build and push Docker image
  42. uses: docker/build-push-action@v6
  43. with:
  44. context: .
  45. push: true
  46. tags: ${{ steps.meta.outputs.tags }}
  47. labels: ${{ steps.meta.outputs.labels }}
  48. # Staging reports to the same PostHog project as production, so its
  49. # source maps go there too (see scripts/upload-source-maps.sh).
  50. build-args: |
  51. APP_VERSION=dev-${{ steps.sha.outputs.short }}
  52. NEXT_ACTIONS_FINGERPRINT=${{ steps.actions_key.outputs.id }}
  53. POSTHOG_SOURCEMAPS=${{ secrets.POSTHOG_SOURCEMAPS_API_KEY != '' && 'on' || 'off' }}
  54. POSTHOG_CLI_HOST=https://eu.posthog.com
  55. POSTHOG_CLI_PROJECT_ID=142584
  56. POSTHOG_UPLOAD_ATTEMPT=${{ github.run_id }}-${{ github.run_attempt }}
  57. # Keeps server action IDs the same from build to build (see the Dockerfile).
  58. secrets: |
  59. next_actions_key=${{ secrets.NEXT_SERVER_ACTIONS_BUILD_KEY }}
  60. posthog_cli_api_key=${{ secrets.POSTHOG_SOURCEMAPS_API_KEY }}
  61. cache-from: type=gha
  62. cache-to: type=gha,mode=max