docker.yml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. name: Build and Push Multi-Arch Docker Images
  2. on:
  3. push:
  4. branches: [master]
  5. tags: ["v*"]
  6. workflow_dispatch:
  7. env:
  8. REGISTRY: docker.io
  9. IMAGE_NAME: wantcat/trendradar
  10. jobs:
  11. build:
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Checkout
  15. uses: actions/checkout@v4
  16. - name: Set up QEMU
  17. uses: docker/setup-qemu-action@v3
  18. - name: Set up Docker Buildx
  19. uses: docker/setup-buildx-action@v3
  20. - name: Login to Docker Hub
  21. uses: docker/login-action@v3
  22. with:
  23. username: ${{ secrets.DOCKERHUB_USERNAME }}
  24. password: ${{ secrets.DOCKERHUB_TOKEN }}
  25. - name: Extract metadata
  26. id: meta
  27. uses: docker/metadata-action@v5
  28. with:
  29. images: ${{ env.IMAGE_NAME }}
  30. tags: |
  31. type=ref,event=branch
  32. type=semver,pattern={{version}}
  33. type=semver,pattern={{major}}.{{minor}}
  34. type=raw,value=latest,enable={{is_default_branch}}
  35. - name: Build and push
  36. uses: docker/build-push-action@v5
  37. with:
  38. context: .
  39. file: ./docker/Dockerfile
  40. platforms: linux/amd64,linux/arm64,linux/arm/v7
  41. push: true
  42. tags: ${{ steps.meta.outputs.tags }}
  43. labels: ${{ steps.meta.outputs.labels }}
  44. cache-from: type=gha
  45. cache-to: type=gha,mode=max