summaryrefslogtreecommitdiffstats
path: root/.github/workflows/docs_release.yaml
blob: d1f91972be2413c1b7550f7c836ca3199b57bb20 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Release documentation

on:
  push:
    branches:
      - 'main'
      - 'stable-**'
    paths:
      - 'ydb/docs/**'
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    concurrency:
      group: release-documentation-${{ github.ref }}
      cancel-in-progress: true
    permissions: write-all
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      # Branches listed below keep the old logic (use-ya-opensource: false).
      # All other branches use the new logic (use-ya-opensource: true).
      # This workflow runs on push / workflow_dispatch, so the relevant branch
      # is the one being built (context.ref), not a pull request base ref.
      - name: Determine ya-opensource flag
        id: ya
        uses: actions/github-script@v8
        with:
          script: |
            const legacyBranches = [
              'stable-25-1',
              'stable-25-2',
              'stable-25-2-1',
              'stable-25-3',
              'stable-25-3-1',
              'stable-25-4',
              'stable-25-4-1',
              'stable-26-1',
              'stable-26-1-1',
              'stable-26-2',
              'stable-26-2-1',
            ];
            const branch = context.ref.replace('refs/heads/', '');
            core.setOutput('use', legacyBranches.includes(branch) ? 'false' : 'true');

      - name: Build
        uses: diplodoc-platform/docs-build-action@v3
        with:
          revision: "${{ github.sha }}"
          src-root: ${{ vars.SRC_ROOT }}
          cli-version: "4.59.12"
          use-ya-opensource: ${{ steps.ya.outputs.use }}

  upload:
    needs: build
    runs-on: ubuntu-latest
    concurrency:
      group: release-documentation-${{ github.ref }}
      cancel-in-progress: true
    permissions: write-all
    steps:
      - name: Upload
        uses: diplodoc-platform/docs-upload-action@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          storage-bucket: "common/${{ secrets.DOCS_PROJECT_NAME }}"
          storage-endpoint: ${{ vars.DOCS_AWS_ENDPOINT }}
          storage-access-key-id: ${{ secrets.DOCS_AWS_KEY_ID }}
          storage-secret-access-key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY }}
          storage-region: ${{ vars.DOCS_AWS_REGION }}

  release:
    needs: upload
    runs-on: ubuntu-latest
    concurrency:
      group: release-documentation-${{ github.ref }}
      cancel-in-progress: true
    steps:
      - name: Extract version # turn branch name into version string
        id: extract_version
        shell: bash
        run: |
          echo "version=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
            | sed -e 's|stable-|v|g' -e 's|-|.|g' \
            >> $GITHUB_OUTPUT

      - name: Get default branch name
        id: get_default
        run: |
          default=$(curl -fsS \
            https://raw.githubusercontent.com/ydb-platform/ydb/refs/heads/main/ydb/docs/default-branch.txt)
          echo "DEFAULT_BRANCH=$default" >> $GITHUB_ENV

      - name: Set update-only-version # only skip default-branch commits
        id: set-update-only-version
        run: |
          current=${GITHUB_REF##*/}    # e.g. 'main' or 'stable-X'
          if [[ "$current" == "$DEFAULT_BRANCH" ]]; then
            echo "update_only_version=false" >> $GITHUB_ENV
          else
            echo "update_only_version=true"  >> $GITHUB_ENV
          fi

      - name: Release
        uses: diplodoc-platform/docs-release-action@v2
        with:
          revision: "${{ github.sha }}"
          version:  "${{ steps.extract_version.outputs.version }}"
          storage-bucket: ${{ secrets.DOCS_PROJECT_NAME }}
          storage-access-key-id: ${{ secrets.DOCS_AWS_KEY_ID }}
          storage-secret-access-key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY }}
          update-only-version: "${{ env.update_only_version }}"