summaryrefslogtreecommitdiffstats
path: root/.github/workflows/add_backport_table.yml
blob: ec120a2a42c4a9c20f1488744647ab06b9ff8b7f (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
name: Add backport table to PR

on:
  pull_request_target:
    types:
      - closed
    branches:
      - main
  workflow_dispatch:
    inputs:
      pr_number:
        description: 'Pull Request number to add backport table to'
        required: true
        type: number

permissions:
  contents: read
  pull-requests: write

env:
  GH_TOKEN: ${{ secrets.YDBOT_TOKEN }}

jobs:
  add-backport-table:
    name: Add backport table to merged PR
    runs-on: [ self-hosted, auto-provisioned, build-preset-analytic-node]
    if: >
      (
        github.event_name == 'workflow_dispatch'
      ) ||
      (
        github.event_name == 'pull_request_target' &&
        github.event.pull_request.merged == true &&
        github.event.pull_request.base.ref == 'main' &&
        vars.SHOW_BACKPORT_IN_PR == 'TRUE'
      )
    
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && github.ref || 'main' }}
          fetch-depth: 1
          sparse-checkout: |
            .github

      - name: Install dependencies
        run: |
          python3 -m pip install --upgrade pip
          pip install PyGithub

      - name: Add backport table to PR
        env:
          GITHUB_TOKEN: ${{ env.GH_TOKEN }}
          GITHUB_EVENT_PATH: ${{ github.event_path }}
          GITHUB_REPOSITORY: ${{ github.repository }}
          GITHUB_WORKSPACE: ${{ github.workspace }}
          APP_DOMAIN: ${{ vars.APP_DOMAIN }}
          SHOW_BACKPORT_IN_PR: ${{ vars.SHOW_BACKPORT_IN_PR }}
          PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || '' }}
        run: |
          python3 ./.github/scripts/add_backport_table.py