docker-dev.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. type=raw,value=dev-latest
  42. - name: Build and push Docker image
  43. uses: docker/build-push-action@v6
  44. with:
  45. context: .
  46. push: true
  47. tags: ${{ steps.meta.outputs.tags }}
  48. labels: ${{ steps.meta.outputs.labels }}
  49. build-args: |
  50. APP_VERSION=dev-${{ steps.sha.outputs.short }}
  51. cache-from: type=gha
  52. cache-to: type=gha,mode=max