auto_build_docker_container.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. name: 自动构建docker镜像
  2. on:
  3. schedule:
  4. - cron: "36 18 * * 0"
  5. watch:
  6. types: started
  7. # workflow_dispatch:
  8. push:
  9. branches: [ main ]
  10. # pull_request:
  11. # branches: [ main ]
  12. jobs:
  13. build:
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Check Out Repo
  17. uses: actions/checkout@v4
  18. # - name: Login to GHCR
  19. # if: github.event_name != 'pull_request'
  20. # uses: docker/login-action@v3
  21. # with:
  22. # registry: ghcr.io
  23. # username: ${{ github.repository_owner }}
  24. # password: ${{ secrets.GITHUB_TOKEN }}
  25. # - name: Login to GitHub Container Registry
  26. # uses: docker/login-action@v3
  27. # with:
  28. # registry: ghcr.io
  29. # username: ${{ github.actor }}
  30. # password: ${{ secrets.GITHUB_TOKEN }}
  31. - name: Login to Docker Hub
  32. uses: docker/login-action@v3
  33. with:
  34. username: ${{ secrets.DOCKER_USERNAME }}
  35. password: ${{ secrets.DOCKER_PASSWORD }}
  36. # - name: Login to Private Docker Registry
  37. # uses: docker/login-action@v3
  38. # with:
  39. # registry: ${{ secrets.DOCKER_REGISTRY }}
  40. # username: ${{ secrets.PRIVATE_USERNAME }}
  41. # password: ${{ secrets.PRIVATE_PASSWORD }}
  42. - name: Get Respository Name
  43. run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> "$GITHUB_ENV"
  44. - name: Docker meta
  45. id: meta
  46. uses: docker/metadata-action@v5
  47. with:
  48. # list of Docker images to use as base name for tags
  49. images: |
  50. ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
  51. # ${{ secrets.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
  52. tags: |
  53. type=raw,value=latest
  54. {{date 'YYYY/MM/DD/hh/mm/ss'}}
  55. # type=schedule,pattern={{date 'YYYY/MM/DD'}}
  56. # type=semver,pattern={{version}}
  57. # type=semver,pattern=$()
  58. # type=ref,event=branch
  59. # type=sha
  60. # type=ref,event=pr
  61. # type=semver,pattern={{major}}.{{minor}}
  62. # type=semver,pattern={{major}}
  63. - name: Set up QEMU
  64. uses: docker/setup-qemu-action@v3
  65. - name: Set up Docker Buildx
  66. id: buildx
  67. uses: docker/setup-buildx-action@v3
  68. - name: Build and push all
  69. id: docker_build_all
  70. uses: docker/build-push-action@v6
  71. with:
  72. context: .
  73. file: Dockerfile
  74. push: true
  75. platforms: linux/amd64,linux/arm64
  76. tags: ${{ steps.meta.outputs.tags }}
  77. labels: ${{ steps.meta.outputs.labels }}
  78. # target:
  79. - name: all Image digest
  80. run: echo ${{ steps.docker_build_all.outputs.digest }}
粤ICP备19079148号