docker-publish.yml 1.3 KB

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