mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-18 00:14:48 +00:00
49 lines
1.7 KiB
YAML
49 lines
1.7 KiB
YAML
name: Label Pending Release
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, reopened, edited, synchronize]
|
|
branches: [dev]
|
|
|
|
jobs:
|
|
label:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
issues: write
|
|
pull-requests: read
|
|
|
|
steps:
|
|
- name: Label linked issues as pending-release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
PR_BODY: ${{ github.event.pull_request.body }}
|
|
run: |
|
|
# Extract issue numbers from PR title/body plus current PR commits.
|
|
# Using env vars prevents shell injection from backticks in markdown.
|
|
COMMIT_TEXT=$(gh api "repos/${{ github.repository }}/pulls/${PR_NUMBER}/commits" --paginate --jq '.[].commit.message' 2>/dev/null || true)
|
|
PR_TEXT="$PR_TITLE
|
|
$PR_BODY
|
|
$COMMIT_TEXT"
|
|
ISSUES=$(echo "$PR_TEXT" | grep -oE "(Fixes|Closes|Resolves|Refs?) #[0-9]+" | grep -oE "#[0-9]+" | sort -u || true)
|
|
|
|
if [[ -z "$ISSUES" ]]; then
|
|
echo "No linked issues found in PR"
|
|
exit 0
|
|
fi
|
|
|
|
for ISSUE in $ISSUES; do
|
|
NUM=${ISSUE#\#}
|
|
echo "Labeling issue #$NUM as pending-release"
|
|
|
|
# Create label if doesn't exist
|
|
gh label create "pending-release" \
|
|
--color "fbca04" \
|
|
--description "Fix in review, awaiting merge" \
|
|
--repo ${{ github.repository }} 2>/dev/null || true
|
|
|
|
# Add label to issue
|
|
gh issue edit $NUM --add-label "pending-release" --repo ${{ github.repository }} || true
|
|
done
|