diff --git a/.github/issue-type-config.json b/.github/issue-type-config.json deleted file mode 100644 index fcf9ce2e..00000000 --- a/.github/issue-type-config.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "types": [ - { - "prefixes": [ - "feat:", - "feature:" - ], - "label": "feature" - }, - { - "prefixes": [ - "fix:", - "bug:" - ], - "label": "bug" - }, - { - "prefixes": [ - "docs:", - "documentation:" - ], - "label": "documentation" - }, - { - "prefixes": [ - "refactor:" - ], - "label": "refactor" - }, - { - "prefixes": [ - "chore:" - ], - "label": "chore" - }, - { - "prefixes": [ - "enhance:", - "enhancement:" - ], - "label": "enhancement" - } - ], - "defaultType": { - "label": "triage" - } -} diff --git a/.github/labels.json b/.github/labels.json index 000dd85c..81c8254b 100644 --- a/.github/labels.json +++ b/.github/labels.json @@ -1,52 +1,62 @@ [ - { - "name": "bug", - "color": "d73a4a", - "description": "Something isn't working" - }, - { - "name": "feature", - "color": "0075ca", - "description": "New feature or request" - }, - { - "name": "documentation", - "color": "0A0A0A", - "description": "Improvements or additions to documentation" - }, - { - "name": "chore", - "color": "cfd3d7", - "description": "Maintenance tasks" - }, - { - "name": "refactor", - "color": "a2eeef", - "description": "Refactoring" - }, - { - "name": "dependencies", - "color": "0366d6", - "description": "Pull requests that update a dependency file" - }, - { - "name": "enhancement", - "color": "a2eeef", - "description": "Enhancement proposal" - }, - { - "name": "triage", - "color": "d4c5f9", - "description": "This issue needs to be triaged" - }, - { - "name": "wontfix", - "color": "ffffff", - "description": "This will not be worked on" - }, - { - "name": "nice to have", - "color": "fef2c0", - "description": "Low priority enhancement that would be nice to have" - } + { + "name": "issue or PR: bug", + "color": "d73a4a", + "description": "Something isn't working as expected" + }, + { + "name": "issue or PR: feature", + "color": "0052cc", + "description": "New feature implementation" + }, + { + "name": "issue or PR: enhancement", + "color": "a2eeef", + "description": "Improvement to existing features" + }, + { + "name": "issue: question", + "color": "d876e3", + "description": "Further information is requested" + }, + { + "name": "status: good first issue", + "color": "7057ff", + "description": "Good for newcomers" + }, + { + "name": "status: help wanted", + "color": "008672", + "description": "Extra attention is needed" + }, + { + "name": "close: duplicate", + "color": "cfd3d7", + "description": "This issue already exists" + }, + { + "name": "close: wontfix", + "color": "ffffff", + "description": "This will not be worked on" + }, + { + "name": "close: invalid", + "color": "e4e669", + "description": "This doesn't seem right" + }, + { + "name": "PR: documentation", + "color": "0075ca", + "description": "Improvements or additions to documentation" + }, + { + "name": "PR: refactor", + "color": "fbca04", + "description": "Code refactoring" + }, + { + "name": "PR: chore", + "color": "bfdadc", + "description": "General maintenance tasks" + } ] diff --git a/.github/workflows/auto-comment-on-unlabeled-issue.yml b/.github/workflows/auto-comment-on-unlabeled-issue.yml new file mode 100644 index 00000000..afbce7aa --- /dev/null +++ b/.github/workflows/auto-comment-on-unlabeled-issue.yml @@ -0,0 +1,67 @@ +name: Auto Comment on Unlabeled Issue + +on: + issues: + types: [opened, edited] + workflow_dispatch: + inputs: + issue_number: + description: "Issue number to process" + required: true + type: number + +jobs: + process_issue: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check issue labels + id: check_labels + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + ISSUE_NUMBER=${{ github.event.inputs.issue_number }} + else + ISSUE_NUMBER="${{ github.event.issue.number }}" + fi + echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT + + ISSUE_DATA=$(gh issue view $ISSUE_NUMBER --json number,title,labels) + ISSUE_TITLE=$(echo "$ISSUE_DATA" | jq -r '.title') + EXISTING_LABELS=$(echo "$ISSUE_DATA" | jq -r '.labels[].name') + + echo "Debug: Current labels: EXISTING_LABELS=$EXISTING_LABELS" + + # Define the labels we want users to add + USER_LABELS="issue or PR: bug|issue or PR: feature|issue or PR: enhancement|issue: question" + + # Check if any of the user labels already exist + if echo "$EXISTING_LABELS" | grep -qE "(${USER_LABELS})" ; then + echo "skip=true" >> $GITHUB_OUTPUT + echo "Skipping comment as relevant labels already exist." + else + echo "skip=false" >> $GITHUB_OUTPUT + fi + + - name: Add comment if no labels + if: steps.check_labels.outputs.skip == 'false' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ steps.check_labels.outputs.issue_number }} + run: | + COMMENT="Thank you for opening this issue. To help us categorize and prioritize it better, please consider adding one of the following labels: + + - issue or PR: bug: Something isn't working as expected + - issue or PR: feature: New feature implementation + - issue or PR: enhancement: Improvement to existing features + - issue: question: Further information is requested + + Adding a label will help our team quickly understand the nature of the issue and address it more efficiently. Thank you for your cooperation!" + + if gh issue comment $ISSUE_NUMBER --body "$COMMENT"; then + echo "Successfully added comment to issue #$ISSUE_NUMBER" + else + echo "Failed to add comment to issue #$ISSUE_NUMBER" + exit 1 + fi diff --git a/.github/workflows/auto-label-issue.yml b/.github/workflows/auto-label-issue.yml deleted file mode 100644 index b2612b4f..00000000 --- a/.github/workflows/auto-label-issue.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Auto Label and Comment Issue - -on: - issues: - types: [opened, edited] - workflow_dispatch: - inputs: - issue_number: - description: 'Issue number to process' - required: true - type: number - -jobs: - process_issue: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Determine label - id: determine_label - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - ISSUE_NUMBER=${{ github.event.inputs.issue_number }} - ISSUE_TITLE=$(gh issue view $ISSUE_NUMBER --json title -q .title) - else - ISSUE_NUMBER="${{ github.event.issue.number }}" - ISSUE_TITLE="${{ github.event.issue.title }}" - fi - echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT - - case "$ISSUE_TITLE" in - feat:* | feature:*) - echo "label=feature" >> $GITHUB_OUTPUT - ;; - fix:* | bug:*) - echo "label=bug" >> $GITHUB_OUTPUT - ;; - docs:* | documentation:*) - echo "label=documentation" >> $GITHUB_OUTPUT - ;; - refactor:*) - echo "label=refactor" >> $GITHUB_OUTPUT - ;; - chore:*) - echo "label=chore" >> $GITHUB_OUTPUT - ;; - enhance:* | enhancement:*) - echo "label=enhancement" >> $GITHUB_OUTPUT - ;; - *) - echo "label=triage" >> $GITHUB_OUTPUT - ;; - esac - - - name: Apply label and add comment if necessary - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ISSUE_NUMBER: ${{ steps.determine_label.outputs.issue_number }} - LABEL: ${{ steps.determine_label.outputs.label }} - run: | - if [ "$LABEL" = "triage" ]; then - COMMENT="Thank you for opening this issue. To help us categorize and prioritize it better, please consider updating the title to start with one of the following prefixes: - - - feat: or feature: for new feature requests - - fix: or bug: for bug reports - - docs: or documentation: for documentation improvements - - refactor: for code refactoring suggestions - - chore: for general maintenance tasks - - enhance: or enhancement: for enhancement proposals - - For example: 'feat: Add user authentication feature' or 'bug: Fix login page crash' - - This will help our team to quickly understand the nature of the issue and address it more efficiently. Thank you for your cooperation!" - - if gh issue comment $ISSUE_NUMBER --body "$COMMENT"; then - echo "Successfully added comment to issue #$ISSUE_NUMBER" - else - echo "Failed to add comment to issue #$ISSUE_NUMBER" - exit 1 - fi - fi - - if gh issue edit $ISSUE_NUMBER --add-label "$LABEL"; then - echo "Successfully added label: $LABEL to issue #$ISSUE_NUMBER" - else - echo "Failed to add label: $LABEL to issue #$ISSUE_NUMBER" - exit 1 - fi \ No newline at end of file diff --git a/.github/workflows/create-branch-on-issue-assign.yml b/.github/workflows/create-branch-on-issue-assign.yml index 4ca22da8..c3c50741 100644 --- a/.github/workflows/create-branch-on-issue-assign.yml +++ b/.github/workflows/create-branch-on-issue-assign.yml @@ -11,7 +11,7 @@ on: type: number jobs: - create_branch: + check_labels_and_create_branch: runs-on: ubuntu-latest permissions: issues: write @@ -20,7 +20,8 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set issue details and create branch + - name: Check labels and create branch + id: check_and_create env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -34,7 +35,6 @@ jobs: ASSIGNEE=$(echo "$ISSUE_DATA" | jq -r '.assignees[0].login // empty') LABELS=$(echo "$ISSUE_DATA" | jq -r '.labels[].name // empty') - echo "Debug: ISSUE_DATA=$ISSUE_DATA" echo "Debug: ASSIGNEE=$ASSIGNEE" echo "Debug: LABELS=$LABELS" @@ -44,21 +44,17 @@ jobs: exit 1 fi - CONFIG_FILE=".github/issue-type-config.json" - BRANCH_LABEL="" - for label in $LABELS; do - if jq -e ".types[] | select(.label == \"$label\")" "$CONFIG_FILE" > /dev/null; then - BRANCH_LABEL="$label" - echo "Debug: Matching label found: $BRANCH_LABEL" - break - fi - done + VALID_LABELS="bug feature enhancement question documentation refactor chore" + BRANCH_LABEL=$(echo "$LABELS" | tr ' ' '\n' | grep -m1 -w "$VALID_LABELS") if [ -z "$BRANCH_LABEL" ]; then - echo "No matching label found in config. Skipping branch creation." + echo "no_valid_label=true" >> $GITHUB_OUTPUT + echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT exit 0 fi + echo "Debug: Matching label found: $BRANCH_LABEL" + BRANCH_NAME="${ASSIGNEE,,}/${BRANCH_LABEL}-issue-${ISSUE_NUMBER}" echo "Debug: BRANCH_NAME=$BRANCH_NAME" @@ -69,3 +65,23 @@ jobs: git push origin "$BRANCH_NAME" gh issue comment $ISSUE_NUMBER --body "Created branch \`$BRANCH_NAME\`" + + - name: Comment on missing label + if: steps.check_and_create.outputs.no_valid_label == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ steps.check_and_create.outputs.issue_number }} + run: | + COMMENT="Thank you for working on this issue. To help us categorize and prioritize it better, please add one of the following labels: + + - bug: Something isn't working as expected + - feature: New feature implementation + - enhancement: Improvement to existing features + - question: Further information is requested + - documentation: Improvements or additions to documentation + - refactor: Code refactoring + - chore: General maintenance tasks + + Adding an appropriate label will help our team quickly understand the nature of the issue and create the correct branch. Once you've added a label, we'll automatically create a branch for this issue. Thank you for your cooperation!" + + gh issue comment $ISSUE_NUMBER --body "$COMMENT" \ No newline at end of file