chore(deps): bump dependabot/fetch-metadata from 2.4.0 to 2.5.0 #21
Workflow file for this run
This file contains hidden or 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: PR Auto Assignment and Labeling | |
| on: | |
| pull_request: | |
| types: [opened, edited] | |
| jobs: | |
| auto-assign-and-label: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Get branch name | |
| id: branch | |
| run: echo "branch_name=${GITHUB_HEAD_REF}" >> $GITHUB_OUTPUT | |
| - name: Determine label based on branch prefix or author | |
| id: label | |
| run: | | |
| # Check if it's a Dependabot PR (using the PR author, not the workflow actor) | |
| if [[ "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" ]]; then | |
| echo "label=dependencies" >> $GITHUB_OUTPUT | |
| # Check branch prefixes | |
| elif [[ "${{ github.head_ref }}" == feature/* ]] || [[ "${{ github.head_ref }}" == feat/* ]]; then | |
| echo "label=enhancement" >> $GITHUB_OUTPUT | |
| elif [[ "${{ github.head_ref }}" == fix/* ]]; then | |
| echo "label=fix" >> $GITHUB_OUTPUT | |
| elif [[ "${{ github.head_ref }}" == docs/* ]]; then | |
| echo "label=documentation" >> $GITHUB_OUTPUT | |
| else | |
| echo "label=" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Add label to PR | |
| if: steps.label.outputs.label != '' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| github.rest.issues.addLabels({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: ['${{ steps.label.outputs.label }}'] | |
| }) | |
| - name: Assign reviewer and assignee | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const assignee = 'baspa'; | |
| const prAuthor = context.payload.pull_request.user.login; | |
| console.log(`PR Author: ${prAuthor}`); | |
| console.log(`Assignee: ${assignee}`); | |
| console.log(`Are they the same? ${prAuthor.toLowerCase() === assignee.toLowerCase()}`); | |
| // Always assign as assignee (you can be assigned to your own PR) | |
| github.rest.issues.addAssignees({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| assignees: [assignee] | |
| }); | |
| console.log(`Assigned ${assignee} as assignee`); | |
| // Only assign reviewer if they are not the PR author (case-insensitive comparison) | |
| if (prAuthor.toLowerCase() !== assignee.toLowerCase()) { | |
| github.rest.pulls.requestReviewers({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| reviewers: [assignee] | |
| }); | |
| console.log(`Assigned ${assignee} as reviewer`); | |
| } else { | |
| console.log(`Skipping reviewer assignment - ${assignee} is the PR author`); | |
| } |