docker_publish.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. name: Publish docker image
  2. on:
  3. schedule:
  4. - cron: "0 3 * * *"
  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. local_ydb_ref:
  23. type: string
  24. required: true
  25. default: main
  26. description: "Git branch/tag revision to build local_ydb"
  27. jobs:
  28. build:
  29. runs-on: [self-hosted, auto-provisioned]
  30. steps:
  31. - name: Checkout .github
  32. uses: actions/checkout@v4
  33. with:
  34. ref: ${{ inputs.dockerfile_branch || 'main' }}
  35. path: main
  36. sparse-checkout: |
  37. .github
  38. - name: Checkout
  39. uses: actions/checkout@v4
  40. with:
  41. ref: ${{ inputs.git_ref || 'main' }}
  42. path: ydb
  43. - name: get revision
  44. shell: bash
  45. id: get-sha
  46. working-directory: ydb
  47. run: |
  48. echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
  49. - name: Set up Docker buildx
  50. uses: docker/setup-buildx-action@v2
  51. - name: Log in to the Container registry
  52. uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
  53. with:
  54. registry: ghcr.io
  55. username: ${{ github.actor }}
  56. password: ${{ secrets.GITHUB_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. labels: |
  64. ydb.revision=${{ steps.get-sha.outputs.SHA }}
  65. org.opencontainers.image.revision=${{ steps.get-sha.outputs.SHA }}
  66. tags: |
  67. type=schedule,pattern=nightly
  68. type=raw,value=${{ inputs.image_tag || 'trunk' }}
  69. - name: Build and push docker image
  70. uses: docker/build-push-action@v4
  71. with:
  72. push: true
  73. context: .
  74. file: main/.github/docker/Dockerfile
  75. tags: ${{ steps.meta.outputs.tags }}
  76. labels: ${{ steps.meta.outputs.labels }}
  77. platforms: linux/amd64
  78. provenance: false
  79. 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 }}
  80. 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