1
0

auto_build_docker_container.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. name: 自动构建docker镜像
  2. on:
  3. schedule:
  4. - cron: "36 19 * * 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 Docker Hub
  26. uses: docker/login-action@v3
  27. with:
  28. username: ${{ secrets.DOCKER_USERNAME }}
  29. password: ${{ secrets.DOCKER_PASSWORD }}
  30. - name: Get Respository Name
  31. run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> "$GITHUB_ENV"
  32. - name: Docker meta
  33. id: meta
  34. uses: docker/metadata-action@v5
  35. with:
  36. # list of Docker images to use as base name for tags
  37. images: |
  38. ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
  39. # ghcr.io/username/app
  40. # generate Docker tags based on the following events/attributes
  41. tags: |
  42. type=raw,value=latest
  43. {{date 'YYYY/MM/DD/hh/mm/ss'}}
  44. # type=schedule,pattern={{date 'YYYY/MM/DD'}}
  45. # type=semver,pattern={{version}}
  46. # type=semver,pattern=$()
  47. # type=ref,event=branch
  48. # type=sha
  49. # type=ref,event=pr
  50. # type=semver,pattern={{major}}.{{minor}}
  51. # type=semver,pattern={{major}}
  52. - name: Set up QEMU
  53. uses: docker/setup-qemu-action@v3
  54. - name: Set up Docker Buildx
  55. id: buildx
  56. uses: docker/setup-buildx-action@v3
  57. - name: Build and push all
  58. id: docker_build_all
  59. uses: docker/build-push-action@v5
  60. with:
  61. context: ./
  62. file: ./Dockerfile
  63. push: true
  64. platforms: linux/amd64,linux/arm64,linux/arm/v7
  65. tags: ${{ steps.meta.outputs.tags }}
  66. labels: ${{ steps.meta.outputs.labels }}
  67. - name: all Image digest
  68. run: echo ${{ steps.docker_build_all.outputs.digest }}
粤ICP备19079148号