Skip to content
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

Add "needs testing" label if contributor comments "ready for testing" #7488

Merged
merged 5 commits into from
May 7, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/auto-testing-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Auto Add Needs Testing Label

on:
pull_request:
types: [opened, reopened, edited]
issue_comment:
types: [created]
pull_request_review:
types: [submitted]

jobs:
auto_label:
runs-on: ubuntu-latest

steps:
- name: Check PR Conditions and Add Label
id: check_conditions
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const isDraft = pr.draft;
const isReadyForTestingComment = context.payload.comment?.body.includes('ready for testing');
const isChangesRequired = context.payload.review?.state === 'changes_requested';

if ((isReadyForTestingComment && !isDraft) || (!isDraft && pr.draft_changed) || isChangesRequired) {
saloni0419 marked this conversation as resolved.
Show resolved Hide resolved
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['needs testing']
});
}

if (isChangesRequired) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we could remove need testing label when changes are requested, not mandatory but good to have

cc: @nihal467

await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: 'Reminder: To add the "needs testing" label, comment "ready for testing" on this PR.'
});
}
Loading