mirror of
https://github.com/keycloak/keycloak.git
synced 2026-02-21 06:39:12 -06:00
Add release labels to issues on merge (#25139)
Signed-off-by: stianst <stianst@gmail.com>
This commit is contained in:
50
.github/workflows/label.yml
vendored
Normal file
50
.github/workflows/label.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Labeler
|
||||
on:
|
||||
pull_request_target:
|
||||
types: closed
|
||||
|
||||
jobs:
|
||||
label:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: .github/scripts
|
||||
- name: Add release labels on merge
|
||||
run: |
|
||||
PR_NUMBER="${{ github.event.pull_request.number }}"
|
||||
|
||||
echo "Base REF: $GITHUB_BASE_REF"
|
||||
echo "PR: https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER"
|
||||
|
||||
if [ "$GITHUB_BASE_REF" == "main" ]; then
|
||||
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)"
|
||||
NEXT_MAJOR="$(($LAST_MAJOR + 1))"
|
||||
LABEL="release/$NEXT_MAJOR.0.0"
|
||||
BACKPORT_LABEL="backport/main"
|
||||
elif [[ "$GITHUB_BASE_REF" = release/* ]]; then
|
||||
MAJOR_MINOR="$(echo $GITHUB_BASE_REF | cut -d '/' -f 2)"
|
||||
LAST_MICRO="$(gh api /repos/$GITHUB_REPOSITORY/tags --jq .[].name | sort -n -r | grep $MAJOR_MINOR | head -n 1 | cut -d '.' -f 3)"
|
||||
NEXT_MICRO="$(($LAST_MICRO + 1))"
|
||||
LABEL="release/$MAJOR_MINOR.$NEXT_MICRO"
|
||||
BACKPORT_LABEL="backport/$MAJOR_MINOR"
|
||||
fi
|
||||
|
||||
echo "Label: $LABEL"
|
||||
|
||||
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"
|
||||
|
||||
echo ""
|
||||
echo "Updating issues:"
|
||||
ISSUES=$(.github/scripts/pr-find-issues.sh "$PR_NUMBER" "$GITHUB_REPOSITORY")
|
||||
for ISSUE in $ISSUES; do
|
||||
gh issue edit "$ISSUE" -R "$GITHUB_REPOSITORY" --add-label "$LABEL" --remove-label "$BACKPORT_LABEL"
|
||||
done
|
||||
if: github.repository == 'keycloak/keycloak' && github.event_name == 'pull_request_target' && github.event.action == 'closed' && github.event.pull_request.merged == true
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
Reference in New Issue
Block a user