aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/docker_publish.yml
blob: 7e509f23aaec0605469520a746f53f753179d95d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Publish docker image

on:
  schedule:
    - cron: "0 3 * * *"
  workflow_dispatch:
    inputs:
      git_ref:
        type: string
        required: true
        default: main
        description: "Git branch/tag revision to build"
      image_tag:
        type: string
        required: true
        default: trunk
        description: "docker image tag"
      local_ydb_ref:
        type: string
        required: true
        default: main
        description: "Git branch/tag revision to builld local_ydb"

jobs:
  build:
    runs-on: [self-hosted, auto-provisioned]
    steps:
      - name: Checkout .github and local_ydb
        uses: actions/checkout@v4
        with:
          ref: main
          path: main
          sparse-checkout: |
            .github
            ydb/public/tools/local_ydb/

      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: ${{ inputs.git_ref || 'main' }}
          path: ydb

      - name: get revision
        shell: bash
        id: get-sha
        working-directory: ydb
        run: |
          echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Log in to the Container registry
        uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: |
            ghcr.io/${{ github.repository_owner }}/local-ydb
          labels: |
            ydb.revision=${{ steps.get-sha.outputs.SHA }}
            org.opencontainers.image.revision=${{ steps.get-sha.outputs.SHA }}
          tags: |
            type=schedule,pattern=nightly
            type=raw,value=${{ inputs.image_tag || 'trunk' }}

      - name: Build and push docker image
        uses: docker/build-push-action@v4
        with:
          push: true
          context: .
          file: main/.github/docker/Dockerfile
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          platforms: linux/amd64
          provenance: false
          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 }}
          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
          secrets: |
            "ccache_remote_storage=${{ vars.REMOTE_CACHE_URL && format('http://{0}{1}', secrets.REMOTE_CACHE_AUTH, vars.REMOTE_CACHE_URL) || ''}}"