docker-dev.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. name: Build Dev Docker Image
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. branch:
  6. description: 'Branch to build from'
  7. required: false
  8. default: 'main'
  9. env:
  10. REGISTRY: ghcr.io
  11. IMAGE_NAME: ${{ github.repository }}
  12. jobs:
  13. build-and-push:
  14. runs-on: ubuntu-latest
  15. permissions:
  16. contents: read
  17. packages: write
  18. steps:
  19. - name: Checkout repository
  20. uses: actions/checkout@v4
  21. with:
  22. ref: ${{ github.event.inputs.branch }}
  23. - name: Set up Docker Buildx
  24. uses: docker/setup-buildx-action@v3
  25. - name: Log in to GitHub Container Registry
  26. uses: docker/login-action@v3
  27. with:
  28. registry: ${{ env.REGISTRY }}
  29. username: ${{ github.actor }}
  30. password: ${{ secrets.GITHUB_TOKEN }}
  31. - name: Get short commit SHA
  32. id: sha
  33. run: echo "short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
  34. - name: Extract metadata (tags, labels)
  35. id: meta
  36. uses: docker/metadata-action@v5
  37. with:
  38. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  39. tags: |
  40. type=raw,value=dev-${{ steps.sha.outputs.short }}
  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. cache-from: type=gha
  51. cache-to: type=gha,mode=max