docker-publish-arm.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. name: Publish Docker Image ARM64
  2. on:
  3. release:
  4. types: [published]
  5. workflow_dispatch:
  6. inputs:
  7. tag:
  8. description: 'Tag to build and publish'
  9. required: true
  10. default: 'latest'
  11. env:
  12. REGISTRY: docker.io
  13. IMAGE_NAME: cashubtc/mintd
  14. jobs:
  15. build-and-push:
  16. runs-on: ubuntu-latest
  17. permissions:
  18. contents: read
  19. packages: write
  20. steps:
  21. - name: Checkout repository
  22. uses: actions/checkout@v4
  23. - name: Set up Docker Buildx
  24. uses: docker/setup-buildx-action@v3
  25. - name: Login to Docker Hub
  26. uses: docker/login-action@v3
  27. with:
  28. username: ${{ secrets.DOCKERHUB_USERNAME }}
  29. password: ${{ secrets.DOCKERHUB_TOKEN }}
  30. - name: Extract metadata (tags, labels) for Docker
  31. id: meta
  32. uses: docker/metadata-action@v5
  33. with:
  34. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  35. tags: |
  36. type=raw,value=latest,enable=${{ github.event_name == 'release' }}
  37. type=semver,pattern={{version}}
  38. type=semver,pattern={{major}}.{{minor}}
  39. type=ref,event=branch
  40. type=ref,event=pr
  41. type=sha
  42. ${{ github.event.inputs.tag != '' && github.event.inputs.tag || '' }}
  43. # Build and push ARM64 image with architecture suffix
  44. - name: Build and push Docker image
  45. uses: docker/build-push-action@v5
  46. with:
  47. context: .
  48. push: true
  49. platforms: linux/arm64
  50. file: ./Dockerfile.arm
  51. tags: ${{ steps.meta.outputs.tags }}-arm64
  52. labels: ${{ steps.meta.outputs.labels }}
  53. cache-from: type=gha
  54. cache-to: type=gha,mode=max
  55. # Create and push multi-arch manifest if both images exist
  56. - name: Create and push multi-arch manifest
  57. run: |
  58. # For each tag in the metadata output
  59. echo "${{ steps.meta.outputs.tags }}" | while read -r tag; do
  60. # Check if AMD64 image exists
  61. if docker manifest inspect $tag-amd64 >/dev/null 2>&1; then
  62. # Create manifest
  63. docker manifest create $tag \
  64. $tag-amd64 \
  65. $tag-arm64
  66. # Annotate the manifest with architecture specific information
  67. docker manifest annotate $tag $tag-amd64 --arch amd64
  68. docker manifest annotate $tag $tag-arm64 --arch arm64
  69. # Push the manifest
  70. docker manifest push $tag
  71. else
  72. echo "AMD64 image not found for $tag, skipping manifest creation"
  73. fi
  74. done