kuma

Форк
0
/
pr-comments.yaml 
81 строка · 3.7 Кб
1
name: pull request comment
2
on:
3
  issue_comment:
4
    types: [created]
5
env:
6
  GH_USER: "github-actions[bot]"
7
  GH_EMAIL: "<41898282+github-actions[bot]@users.noreply.github.com>"
8
  CI_TOOLS_DIR: /home/runner/work/kuma/kuma/.ci_tools
9
permissions:
10
  contents: read
11
jobs:
12
  pr_comments:
13
    timeout-minutes: 30
14
    if: github.event.issue.pull_request != '' && (contains(github.event.comment.body, '/format') || contains(github.event.comment.body, '/golden_files'))
15
    runs-on: ubuntu-latest
16
    steps:
17
      - name: Generate GitHub app token
18
        id: github-app-token
19
        uses: actions/create-github-app-token@f4c6bf6752984b3a29fcc135a5e70eb792c40c6b # v1.8.0
20
        with:
21
          app-id: ${{ secrets.APP_ID }}
22
          private-key: ${{ secrets.APP_PRIVATE_KEY }}
23
      - name: check-maintainer
24
        run: |
25
          # Ensure the commenter is a maintainer
26
          if [[ `gh api  '/repos/${{ github.repository }}/collaborators?permission=maintain' --paginate --jq '.[].login' | grep ${{ github.event.comment.user.login }}` ]]; then
27
            gh api --method POST -f content='+1' ${{ github.event.comment.url }}/reactions
28
          else
29
            gh api --method POST -f content='-1' ${{ github.event.comment.url }}/reactions
30
            echo "${{ github.event.comment.user.login }} is not a maintainer of the repo, can't run this action"
31
            exit 1
32
          fi
33
        env:
34
          GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}
35
      - id: get-branch
36
        run: |
37
          echo "BRANCH_NAME=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefName --jq '.headRefName')" >> $GITHUB_ENV
38
          echo "REPO=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRepository,headRepositoryOwner --jq '[.headRepositoryOwner.login,.headRepository.name] | join("/")')" >> $GITHUB_ENV
39
        env:
40
          GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}
41
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
42
        with:
43
          fetch-depth: 0
44
          repository: ${{ env.REPO }}
45
          ref: ${{ env.BRANCH_NAME }}
46
          token: ${{ steps.github-app-token.outputs.token }}
47
      - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
48
        with:
49
          go-version-file: go.mod
50
      - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
51
        with:
52
          path: |
53
            ${{ env.CI_TOOLS_DIR }}
54
          key: ${{ runner.os }}-${{ runner.arch }}-devtools-${{ hashFiles('mk/dependencies/deps.lock') }}
55
          restore-keys: |
56
            ${{ runner.os }}-${{ runner.arch }}-devtools
57
      - run: |
58
          make dev/tools
59
      - name: format
60
        if: contains(github.event.comment.body, '/format') # check the comment if it contains the keywords
61
        run: |
62
          make clean/generated generate format
63
      - name: run golden_files
64
        if: contains(github.event.comment.body, '/golden_files') # check the comment if it contains the keywords
65
        run: |
66
          make test UPDATE_GOLDEN_FILES=true
67
      - name: commit and push fixes
68
        env:
69
          GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}
70
        run: |
71
          if git diff --exit-code --stat; then
72
            echo "No change detected, skipping git push"
73
          else
74
            git config user.name "${GH_USER}"
75
            git config user.email "${GH_EMAIL}"
76
            git commit -s -m "fix(ci): format files" .
77
            git push
78
          fi
79
      - run: gh api --method POST -f content='hooray' ${{ github.event.comment.url }}/reactions
80
        env:
81
          GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}
82

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.