diff --git a/.github/workflows/comment-pr.yml b/.github/workflows/comment-pr.yml new file mode 100644 index 0000000..219d07f --- /dev/null +++ b/.github/workflows/comment-pr.yml @@ -0,0 +1,58 @@ +name: 'Add Labels on PR Events' + +on: + issue_comment: + types: [created] + pull_request_review: + types: [submitted] + +jobs: + add-label: + runs-on: ubuntu-latest + steps: + - name: 'Checkout code' + uses: actions/checkout@v4 + + - name: 'Determine event type' + id: event-type + run: echo "::set-output name=event_type::${{ github.event_name }}" + + - name: 'Extract Commentator Name' + if: ${{ steps.event-type.outputs.event_type == 'issue_comment' }} + id: extract-commentator + run: echo "::set-output name=commentator::${{ github.event.comment.user.login }}" + + - name: 'Create or update label for comment' + if: ${{ steps.event-type.outputs.event_type == 'issue_comment' }} + uses: peter-evans/create-or-update-label@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: 'commented-by-${{ steps.extract-commentator.outputs.commentator }}' + color: 'FF5733' # Choose a color for the label + + - name: 'Apply label to PR for comment' + if: ${{ steps.event-type.outputs.event_type == 'issue_comment' }} + uses: actions-ecosystem/action-add-labels@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + labels: 'commented-by-${{ steps.extract-commentator.outputs.commentator }}' + + - name: 'Extract Reviewer Name' + if: ${{ steps.event-type.outputs.event_type == 'pull_request_review' && github.event.review.state == 'changes_requested' }} + id: extract-reviewer + run: echo "::set-output name=reviewer::${{ github.event.review.user.login }}" + + - name: 'Create or update label for review' + if: ${{ steps.event-type.outputs.event_type == 'pull_request_review' && github.event.review.state == 'changes_requested' }} + uses: peter-evans/create-or-update-label@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: 'changes-requested-by-${{ steps.extract-reviewer.outputs.reviewer }}' + color: 'FF0000' # Choose a color for the label + + - name: 'Apply label to PR for review' + if: ${{ steps.event-type.outputs.event_type == 'pull_request_review' && github.event.review.state == 'changes_requested' }} + uses: actions-ecosystem/action-add-labels@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + labels: 'changes-requested-by-${{ steps.extract-reviewer.outputs.reviewer }}' diff --git a/.github/workflows/size_labeler.yml b/.github/workflows/size-labeler.yml similarity index 100% rename from .github/workflows/size_labeler.yml rename to .github/workflows/size-labeler.yml