docker.yml 1.3 KB

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