docker-dev.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. build-args: |
  49. APP_VERSION=dev-${{ steps.sha.outputs.short }}
  50. NEXT_ACTIONS_FINGERPRINT=${{ steps.actions_key.outputs.id }}
  51. # Keeps server action IDs the same from build to build (see the Dockerfile).
  52. secrets: |
  53. next_actions_key=${{ secrets.NEXT_SERVER_ACTIONS_BUILD_KEY }}
  54. cache-from: type=gha
  55. cache-to: type=gha,mode=max