-
Notifications
You must be signed in to change notification settings - Fork 423
ci: add backport labels automatically when a new minor version is released #6615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,8 +153,78 @@ jobs: | |
| echo "EOF" | ||
| } >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Post summary | ||
| - name: Ensure release labels | ||
| if: steps.check_version.outputs.is_minor_bump == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.PR_GH_TOKEN || secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| set -euo pipefail | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [quality] medium Priority Issue: Inconsistent error handling pattern |
||
|
|
||
| BRANCH_BASE="${{ steps.check_version.outputs.branch_base }}" | ||
|
|
||
| if [[ -z "$BRANCH_BASE" ]]; then | ||
| echo "::error::Branch base not set; unable to manage labels" | ||
| exit 1 | ||
DrJKL marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
| declare -A COLORS=( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [quality] medium Priority Issue: Hardcoded color values in associative array without validation |
||
| [core]="4361ee" | ||
| [cloud]="4f6ef5" | ||
| ) | ||
|
|
||
| for PREFIX in core cloud; do | ||
| LABEL="${PREFIX}/${BRANCH_BASE}" | ||
| COLOR="${COLORS[$PREFIX]}" | ||
| DESCRIPTION="Backport PRs for ${PREFIX} ${BRANCH_BASE}" | ||
|
|
||
| if gh label view "$LABEL" >/dev/null 2>&1; then | ||
| gh label edit "$LABEL" \ | ||
| --color "$COLOR" \ | ||
| --description "$DESCRIPTION" | ||
| echo "🔄 Updated label $LABEL" | ||
| else | ||
| gh label create "$LABEL" \ | ||
| --color "$COLOR" \ | ||
| --description "$DESCRIPTION" | ||
| echo "✨ Created label $LABEL" | ||
| fi | ||
| done | ||
|
|
||
| MIN_LABELS_TO_KEEP=3 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [quality] low Priority Issue: Magic numbers used without clear reasoning |
||
| MAX_LABELS_TO_FETCH=200 | ||
|
|
||
| for PREFIX in core cloud; do | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [architecture] low Priority Issue: Missing conditional execution guard for label cleanup |
||
| mapfile -t LABELS < <( | ||
| gh label list \ | ||
| --json name \ | ||
| --limit "$MAX_LABELS_TO_FETCH" \ | ||
| --jq '.[].name' | | ||
| grep -E "^${PREFIX}/[0-9]+\.[0-9]+$" | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also |
||
| sort -t/ -k2,2V | ||
| ) | ||
|
|
||
| TOTAL=${#LABELS[@]} | ||
|
|
||
| if (( TOTAL <= MIN_LABELS_TO_KEEP )); then | ||
| echo "ℹ️ Nothing to prune for $PREFIX labels" | ||
| continue | ||
| fi | ||
|
|
||
| REMOVE_COUNT=$((TOTAL - MIN_LABELS_TO_KEEP)) | ||
|
|
||
| if (( REMOVE_COUNT > 1 )); then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [quality] medium Priority Issue: Label deletion logic has potential off-by-one errors |
||
| REMOVE_COUNT=1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete 1 per run? |
||
| fi | ||
|
|
||
| for ((i=0; i<REMOVE_COUNT; i++)); do | ||
| OLD_LABEL="${LABELS[$i]}" | ||
| gh label delete "$OLD_LABEL" --yes | ||
| echo "🗑️ Removed old label $OLD_LABEL" | ||
| done | ||
| done | ||
|
|
||
| - name: Post summary | ||
| if: always() && steps.check_version.outputs.is_minor_bump == 'true' | ||
| run: | | ||
| CURRENT_VERSION="${{ steps.check_version.outputs.current_version }}" | ||
| RESULTS="${{ steps.create_branches.outputs.results }}" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[security] high Priority
Issue: Secrets are potentially exposed via environment variables with fallback pattern
Context: Using secrets.PR_GH_TOKEN || secrets.GITHUB_TOKEN pattern can leak token usage in logs
Suggestion: Use explicit conditional logic or ensure proper token scoping with minimal permissions