docker-image-nightly.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. name: Publish Docker image (nightly)
  2. on:
  3. push:
  4. branches:
  5. - nightly
  6. workflow_dispatch:
  7. inputs:
  8. name:
  9. description: "reason"
  10. required: false
  11. jobs:
  12. build_single_arch:
  13. name: Build & push (${{ matrix.arch }}) [native]
  14. strategy:
  15. fail-fast: false
  16. matrix:
  17. include:
  18. - arch: amd64
  19. platform: linux/amd64
  20. runner: ubuntu-latest
  21. - arch: arm64
  22. platform: linux/arm64
  23. runner: ubuntu-24.04-arm
  24. runs-on: ${{ matrix.runner }}
  25. permissions:
  26. contents: read
  27. steps:
  28. - name: Check out (shallow)
  29. uses: actions/checkout@v4
  30. with:
  31. fetch-depth: 1
  32. - name: Determine nightly version
  33. id: version
  34. run: |
  35. VERSION="nightly-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
  36. echo "$VERSION" > VERSION
  37. echo "value=$VERSION" >> $GITHUB_OUTPUT
  38. echo "VERSION=$VERSION" >> $GITHUB_ENV
  39. echo "Publishing version: $VERSION for ${{ matrix.arch }}"
  40. - name: Set up Docker Buildx
  41. uses: docker/setup-buildx-action@v3
  42. - name: Log in to Docker Hub
  43. uses: docker/login-action@v3
  44. with:
  45. username: ${{ secrets.DOCKERHUB_USERNAME }}
  46. password: ${{ secrets.DOCKERHUB_TOKEN }}
  47. - name: Extract metadata (labels)
  48. id: meta
  49. uses: docker/metadata-action@v5
  50. with:
  51. images: |
  52. calciumion/new-api
  53. - name: Build & push single-arch
  54. uses: docker/build-push-action@v6
  55. with:
  56. context: .
  57. platforms: ${{ matrix.platform }}
  58. push: true
  59. tags: |
  60. calciumion/new-api:nightly-${{ matrix.arch }}
  61. calciumion/new-api:${{ steps.version.outputs.value }}-${{ matrix.arch }}
  62. labels: ${{ steps.meta.outputs.labels }}
  63. cache-from: type=gha
  64. cache-to: type=gha,mode=max
  65. provenance: false
  66. sbom: false
  67. create_manifests:
  68. name: Create multi-arch manifests (Docker Hub)
  69. needs: [build_single_arch]
  70. runs-on: ubuntu-latest
  71. steps:
  72. - name: Check out (shallow)
  73. uses: actions/checkout@v4
  74. with:
  75. fetch-depth: 1
  76. - name: Determine nightly version
  77. id: version
  78. run: |
  79. VERSION="nightly-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
  80. echo "value=$VERSION" >> $GITHUB_OUTPUT
  81. echo "VERSION=$VERSION" >> $GITHUB_ENV
  82. - name: Log in to Docker Hub
  83. uses: docker/login-action@v3
  84. with:
  85. username: ${{ secrets.DOCKERHUB_USERNAME }}
  86. password: ${{ secrets.DOCKERHUB_TOKEN }}
  87. - name: Create & push manifest (Docker Hub - nightly)
  88. run: |
  89. docker buildx imagetools create \
  90. -t calciumion/new-api:nightly \
  91. calciumion/new-api:nightly-amd64 \
  92. calciumion/new-api:nightly-arm64
  93. - name: Create & push manifest (Docker Hub - versioned nightly)
  94. run: |
  95. docker buildx imagetools create \
  96. -t calciumion/new-api:${VERSION} \
  97. calciumion/new-api:${VERSION}-amd64 \
  98. calciumion/new-api:${VERSION}-arm64