Skip to content

Commit

Permalink
fix workflow error and removes needs testing label if changes are req…
Browse files Browse the repository at this point in the history
…uested (#7982)
  • Loading branch information
UdaySagar-Git authored Jun 14, 2024
1 parent 655202d commit 07e0ca0
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions .github/workflows/auto-testing-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,37 @@ jobs:
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';
const comment = context.payload.comment;
const review = context.payload.review;
if ((isReadyForTestingComment && !isDraft) || (!isDraft && pr.draft_changed)) {
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['needs testing']
});
}
if (pr) {
const isDraft = pr.draft;
const isReadyForTestingComment = comment && comment.body.includes('ready for testing');
const isChangesRequired = review && review.state === 'changes_requested';
if ((isReadyForTestingComment && !isDraft) || (!isDraft && pr.draft_changed)) {
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['needs testing']
});
}
if (isChangesRequired) {
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.'
});
if (isChangesRequired) {
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.'
});
if (pr.labels.some(label => label.name === 'needs testing')) {
await github.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
name: 'needs testing'
});
}
}
}

0 comments on commit 07e0ca0

Please sign in to comment.