Update assign-user.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Auto Label Assignment' | |
on: | |
issues: | |
types: [opened] | |
pull_request_target: # Changed to pull_request_target | |
types: [opened] | |
permissions: # Set permissions for the workflow | |
issues: write | |
pull-requests: write | |
jobs: | |
assign-labels: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up GitHub CLI | |
run: | | |
echo "Setting up GitHub CLI" | |
sudo apt-get install gh | |
- name: Assign always-required labels | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Set the GH_TOKEN environment variable | |
run: | | |
# Always add these labels | |
echo "Adding always assigned labels: hacktoberfest, hacktoberfest-accepted, hactoberfest2024" | |
gh pr edit ${{ github.event.pull_request.number }} --add-label "hacktoberfest" | |
gh pr edit ${{ github.event.pull_request.number }} --add-label "hacktoberfest-accepted" | |
gh pr edit ${{ github.event.pull_request.number }} --add-label "hactoberfest2024" | |
- name: Auto assign specific labels based on conditions | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Set the GH_TOKEN environment variable | |
run: | | |
ISSUE_TITLE="${{ github.event.issue.title || github.event.pull_request.title }}" | |
# Conditional label assignment based on title | |
if [[ "${ISSUE_TITLE,,}" =~ "bug" ]]; then | |
echo "Adding label 'bug'" | |
gh issue edit ${{ github.event.issue.number || github.event.pull_request.number }} --add-label "bug" | |
elif [[ "${ISSUE_TITLE,,}" =~ "documentation" ]]; then | |
echo "Adding label 'documentation'" | |
gh issue edit ${{ github.event.issue.number || github.event.pull_request.number }} --add-label "documentation" | |
elif [[ "${ISSUE_TITLE,,}" =~ "enhancement" ]]; then | |
echo "Adding label 'enhancement'" | |
gh issue edit ${{ github.event.issue.number || github.event.pull_request.number }} --add-label "enhancement" | |
else | |
echo "No additional matching label found for this issue or PR." |