Keycloak

Форк
0
57 строк · 2.7 Кб
1
name: Labeller
2
on:
3
  pull_request_target:
4
    types: closed
5

6
jobs:
7
  label:
8

9
    runs-on: ubuntu-latest
10
    permissions:
11
      contents: read
12
      issues: write
13

14
    steps:
15
      - uses: actions/checkout@v4
16
        with:
17
          sparse-checkout: .github/scripts
18
      - name: Add release labels on merge
19
        run: |
20
          PR_NUMBER="${{ github.event.pull_request.number }}"
21
          
22
          echo "Base REF:   $GITHUB_BASE_REF"
23
          echo "**Branch:** [$GITHUB_BASE_REF](https://github.com/$GITHUB_REPOSITORY/tree/$GITHUB_BASE_REF)" >> $GITHUB_STEP_SUMMARY
24
          echo "PR:         https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER"
25
          echo "**PR:** [$PR_NUMBER](https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER)" >> $GITHUB_STEP_SUMMARY
26
          
27
          if [ "$GITHUB_BASE_REF" == "main" ]; then
28
            LAST_MAJOR="$(gh api /repos/$GITHUB_REPOSITORY/branches --paginate --jq .[].name | grep '^release/' | cut -d '/' -f 2 | cut -d '.' -f 1 | sort -n -r | head -n 1)"
29
            NEXT_MAJOR="$(($LAST_MAJOR + 1))"
30
            LABEL="release/$NEXT_MAJOR.0.0"
31
            BACKPORT_LABEL="backport/main"
32
          elif [[ "$GITHUB_BASE_REF" = release/* ]]; then
33
            MAJOR_MINOR="$(echo $GITHUB_BASE_REF | cut -d '/' -f 2)"
34
            LAST_MICRO="$(gh api /repos/$GITHUB_REPOSITORY/tags --jq .[].name | sort -n -r | grep $MAJOR_MINOR | head -n 1 | cut -d '.' -f 3)"
35
            NEXT_MICRO="$(($LAST_MICRO + 1))"
36
            LABEL="release/$MAJOR_MINOR.$NEXT_MICRO"
37
            BACKPORT_LABEL="backport/$MAJOR_MINOR"
38
          fi
39
          
40
          echo "Label:      $LABEL"
41
          echo "**Label:** [$LABEL](https://github.com/$GITHUB_REPOSITORY/labels/$(echo $LABEL | sed 's|/|%2F|g'))" >> $GITHUB_STEP_SUMMARY
42
          
43
          gh api "repos/$GITHUB_REPOSITORY/labels/$(echo $LABEL | sed 's|/|%2F|g')" --silent 2>/dev/null || gh label create -R "$GITHUB_REPOSITORY" "$LABEL" -c "0E8A16"
44
          
45
          echo ""
46
          echo "" >> $GITHUB_STEP_SUMMARY
47
          echo "Updating issues:"
48
          echo "**Updating issues:**" >> $GITHUB_STEP_SUMMARY
49
          
50
          ISSUES=$(.github/scripts/pr-find-issues.sh "$PR_NUMBER" "$GITHUB_REPOSITORY")
51
          for ISSUE in $ISSUES; do
52
            gh issue edit "$ISSUE" -R "$GITHUB_REPOSITORY" --add-label "$LABEL" --remove-label "$BACKPORT_LABEL"
53
            echo "* [$ISSUE](https://github.com/$GITHUB_REPOSITORY/issues/$ISSUE)" >> $GITHUB_STEP_SUMMARY
54
          done
55
        if: github.repository	== 'keycloak/keycloak' && github.event_name == 'pull_request_target' && github.event.action == 'closed' && github.event.pull_request.merged == true
56
        env:
57
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
58

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

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

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

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