docker_publish.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. name: CI
  2. on:
  3. push:
  4. branches:
  5. - main
  6. - feat/*
  7. - develop
  8. tags:
  9. - v*
  10. jobs:
  11. build:
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Checkout code
  15. uses: actions/checkout@v3
  16. - name: Set up QEMU for ARM emulation
  17. uses: docker/setup-qemu-action@v2
  18. with:
  19. platforms: linux/amd64,linux/arm64
  20. - name: Login to ALIYUN Docker Hub
  21. uses: docker/login-action@v1
  22. with:
  23. username: ${{ secrets.ALIYUN_DOCKER_HUB_USERNAME }}
  24. password: ${{ secrets.ALIYUN_DOCKER_HUB_ACCESS_TOKEN }}
  25. registry: registry.cn-hangzhou.aliyuncs.com
  26. - name: Set Docker tag
  27. id: docker_tag
  28. run: |
  29. if [ "${{ github.event_name }}" == "push" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then
  30. # Tag push, use the tag name directly
  31. echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV
  32. else
  33. # Branch push, use branch name and short commit ID
  34. if [ "${{ github.ref_name }}" == "main" ]; then
  35. echo "tag=main-latest" >> $GITHUB_ENV
  36. else
  37. branch=$(echo "${{ github.ref_name }}" | sed 's/\//-/g')
  38. short_sha=$(echo "${{ github.sha }}" | cut -c1-8)
  39. echo "tag=${branch}-${short_sha}" >> $GITHUB_ENV
  40. fi
  41. fi
  42. - name: Build and push adhweb docker image
  43. run: |
  44. docker buildx create --use
  45. docker buildx build --platform linux/amd64,linux/arm64 -t ${{secrets.ALIYUN_DOCKER_HUB_NAMESPACE}}/adh-web:${{ env.tag }} -f docker/adhWeb.Dockerfile . --push
  46. - name: Build and push adhserver docker image
  47. run: |
  48. docker buildx create --use
  49. docker buildx build --platform linux/amd64,linux/arm64 -t ${{secrets.ALIYUN_DOCKER_HUB_NAMESPACE}}/adh-api:${{ env.tag }} -f docker/adhServer.Dockerfile . --push