docker-publish.yml 1.3 KB

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