docker_publish.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. name: Publish docker image
  2. on:
  3. schedule:
  4. - cron: "0 3 * * *" # At 03:00 every day
  5. workflow_dispatch:
  6. inputs:
  7. git_ref:
  8. type: string
  9. required: true
  10. default: main
  11. description: "Git branch/tag revision to build"
  12. dockerfile_branch:
  13. type: string
  14. required: true
  15. default: main
  16. description: "Git branch for getting Dockerfile"
  17. image_tag:
  18. type: string
  19. required: true
  20. default: trunk
  21. description: "docker image tag"
  22. jobs:
  23. build:
  24. runs-on: [self-hosted, auto-provisioned]
  25. steps:
  26. - name: Checkout .github
  27. uses: actions/checkout@v4
  28. with:
  29. ref: ${{ inputs.dockerfile_branch || 'main' }}
  30. path: main
  31. sparse-checkout: |
  32. .github
  33. - name: Checkout
  34. uses: actions/checkout@v4
  35. with:
  36. ref: ${{ inputs.git_ref || 'main' }}
  37. path: ydb
  38. - name: get revision
  39. shell: bash
  40. id: get-sha
  41. working-directory: ydb
  42. run: |
  43. echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
  44. - name: Set up Docker buildx
  45. uses: docker/setup-buildx-action@v2
  46. - name: Log in to the Container registry
  47. uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
  48. with:
  49. registry: ghcr.io
  50. username: ${{ github.actor }}
  51. password: ${{ secrets.GITHUB_TOKEN }}
  52. - name: Log in to the Docker Hub
  53. uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
  54. with:
  55. username: ${{ vars.DOCKER_HUB_USER_NAME }}
  56. password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  57. - name: Docker meta
  58. id: meta
  59. uses: docker/metadata-action@v4
  60. with:
  61. images: |
  62. ghcr.io/${{ github.repository_owner }}/local-ydb
  63. ${{ vars.DOCKER_HUB_REPOSITORY && vars.DOCKER_HUB_REPOSITORY || '' }}
  64. labels: |
  65. ydb.revision=${{ steps.get-sha.outputs.SHA }}
  66. org.opencontainers.image.revision=${{ steps.get-sha.outputs.SHA }}
  67. tags: |
  68. type=schedule,pattern=nightly
  69. type=raw,value=${{ inputs.image_tag || 'trunk' }}
  70. - name: Build and push docker image
  71. uses: docker/build-push-action@v4
  72. with:
  73. push: true
  74. context: .
  75. file: main/.github/docker/Dockerfile
  76. tags: ${{ steps.meta.outputs.tags }}
  77. labels: ${{ steps.meta.outputs.labels }}
  78. platforms: linux/amd64
  79. provenance: false
  80. cache-from: type=s3,name=local_ydb,region=ru-central1,bucket=${{ vars.AWS_BUCKET }},endpoint_url=${{ vars.AWS_ENDPOINT }},access_key_id=${{ secrets.AWS_KEY_ID }},secret_access_key=${{ secrets.AWS_KEY_VALUE }}
  81. cache-to: type=s3,name=local_ydb,region=ru-central1,bucket=${{ vars.AWS_BUCKET }},endpoint_url=${{ vars.AWS_ENDPOINT }},access_key_id=${{ secrets.AWS_KEY_ID }},secret_access_key=${{ secrets.AWS_KEY_VALUE }},mode=max