docker-publish.yml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #
  2. # Copyright 2024 Apollo Authors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. name: Publish Docker Image
  17. on:
  18. workflow_dispatch:
  19. inputs:
  20. version:
  21. description: 'version'
  22. required: true
  23. jobs:
  24. check:
  25. runs-on: ubuntu-latest
  26. outputs:
  27. apollo-config-tags: ${{ steps.check-tags.outputs.apollo-config-tags }}
  28. apollo-admin-tags: ${{ steps.check-tags.outputs.apollo-admin-tags }}
  29. apollo-portal-tags: ${{ steps.check-tags.outputs.apollo-portal-tags }}
  30. steps:
  31. - id: check-tags
  32. name: Check tags
  33. run: |
  34. if [[ ${{ github.event.inputs.version }} == *-SNAPSHOT ]]; then
  35. echo "apollo-config-tags=apolloconfig/apollo-configservice:${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
  36. echo "apollo-admin-tags=apolloconfig/apollo-adminservice:${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
  37. echo "apollo-portal-tags=apolloconfig/apollo-portal:${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
  38. else
  39. echo "apollo-config-tags=apolloconfig/apollo-configservice:${{ github.event.inputs.version }},apolloconfig/apollo-configservice:latest" >> $GITHUB_OUTPUT
  40. echo "apollo-admin-tags=apolloconfig/apollo-adminservice:${{ github.event.inputs.version }},apolloconfig/apollo-adminservice:latest" >> $GITHUB_OUTPUT
  41. echo "apollo-portal-tags=apolloconfig/apollo-portal:${{ github.event.inputs.version }},apolloconfig/apollo-portal:latest" >> $GITHUB_OUTPUT
  42. fi
  43. publish:
  44. needs: check
  45. runs-on: ubuntu-latest
  46. steps:
  47. - name: Checkout
  48. uses: actions/checkout@v3
  49. - name: Set up JDK
  50. uses: actions/setup-java@v1
  51. with:
  52. java-version: 8
  53. - name: Build package
  54. run: ./scripts/build.sh
  55. - name: Login to Docker Hub
  56. uses: docker/login-action@v2
  57. with:
  58. username: ${{ secrets.DOCKER_HUB_USER_NAME }}
  59. password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  60. - name: Set up QEMU
  61. uses: docker/setup-qemu-action@v2
  62. - name: Set up Docker Buildx
  63. uses: docker/setup-buildx-action@v2
  64. - name: Build and push apollo-configservice
  65. uses: docker/build-push-action@v3
  66. with:
  67. context: ./apollo-configservice/target
  68. platforms: linux/amd64,linux/arm64
  69. file: ./apollo-configservice/src/main/docker/Dockerfile
  70. push: true
  71. build-args: VERSION=${{ github.event.inputs.version }}
  72. tags: ${{ needs.check.outputs.apollo-config-tags }}
  73. - name: Build and push apollo-adminservice
  74. uses: docker/build-push-action@v3
  75. with:
  76. context: ./apollo-adminservice/target
  77. platforms: linux/amd64,linux/arm64
  78. file: ./apollo-adminservice/src/main/docker/Dockerfile
  79. push: true
  80. build-args: VERSION=${{ github.event.inputs.version }}
  81. tags: ${{ needs.check.outputs.apollo-admin-tags }}
  82. - name: Build and push apollo-portal
  83. uses: docker/build-push-action@v3
  84. with:
  85. context: ./apollo-portal/target
  86. platforms: linux/amd64,linux/arm64
  87. file: ./apollo-portal/src/main/docker/Dockerfile
  88. push: true
  89. build-args: VERSION=${{ github.event.inputs.version }}
  90. tags: ${{ needs.check.outputs.apollo-portal-tags }}