docker-publish.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. name: Docker
  2. on:
  3. push:
  4. branches: [ "main" ]
  5. paths:
  6. - 'Dockerfile'
  7. - 'requirements.txt'
  8. - 'VERSION'
  9. # Allow manual trigger on any branch
  10. workflow_dispatch:
  11. inputs:
  12. branch:
  13. description: 'Branch to build from'
  14. required: false
  15. default: ''
  16. env:
  17. REGISTRY: ghcr.io
  18. IMAGE_NAME: ${{ github.repository }}
  19. jobs:
  20. build:
  21. runs-on: ubuntu-latest
  22. permissions:
  23. contents: read
  24. packages: write
  25. id-token: write
  26. steps:
  27. - name: Checkout repository
  28. uses: actions/checkout@v4
  29. - name: Set up Docker Buildx
  30. uses: docker/setup-buildx-action@v3
  31. - name: Log into registry ${{ env.REGISTRY }}
  32. if: github.event_name != 'pull_request'
  33. uses: docker/login-action@v3
  34. with:
  35. registry: ${{ env.REGISTRY }}
  36. username: ${{ github.actor }}
  37. password: ${{ secrets.GITHUB_TOKEN }}
  38. - name: Extract Docker metadata
  39. id: meta
  40. uses: docker/metadata-action@v5
  41. with:
  42. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  43. - name: Build and push Docker image for Raspberry Pi
  44. id: build-and-push
  45. uses: docker/build-push-action@v5
  46. with:
  47. context: .
  48. push: ${{ github.event_name != 'pull_request' }}
  49. tags: ${{ steps.meta.outputs.tags }}
  50. labels: ${{ steps.meta.outputs.labels }}
  51. platforms: linux/amd64,linux/arm64
  52. cache-from: type=gha
  53. cache-to: type=gha,mode=max