1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00
This commit is contained in:
FredrikOseberg 2024-12-09 15:44:44 +01:00
parent 5513a9183a
commit 72e535d5f0
No known key found for this signature in database
GPG Key ID: 282FD8A6D8F9BCF0

View File

@ -30,6 +30,7 @@ jobs:
script: | script: |
const prNumber = context.payload.pull_request.number; const prNumber = context.payload.pull_request.number;
// Check if a comment already exists
const comments = await github.rest.issues.listComments({ const comments = await github.rest.issues.listComments({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@ -49,31 +50,35 @@ jobs:
const hasReviewers = reviewers.data.users.length > 0; const hasReviewers = reviewers.data.users.length > 0;
return { hasComment, hasReviewers }; core.setOutput('hasComment', hasComment);
core.setOutput('hasReviewers', hasReviewers);
outputs:
hasComment: ${{ steps.check-comment.outputs.hasComment }}
hasReviewers: ${{ steps.check-comment.outputs.hasReviewers }}
- name: Add reviewers and comment if necessary - name: Add reviewers and comment if necessary
if: steps.check-comment.outputs.hasComment == 'false' || steps.check-comment.outputs.hasReviewers == 'false'
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
script: | script: |
const prNumber = context.payload.pull_request.number; const prNumber = context.payload.pull_request.number;
const prCreator = context.payload.pull_request.user.login; const prCreator = context.payload.pull_request.user.login;
// Add a comment if not already present
if (!${{ steps.check-comment.outputs.hasComment }}) {
await github.rest.issues.createComment({ await github.rest.issues.createComment({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: prNumber, issue_number: prNumber,
body: `@${prCreator}, core features have been modified in this pull request. Reviewers have been added.`, body: `@${prCreator}, core features have been modified in this pull request. Reviewers have been added.`,
}); });
}
// Add reviewers if not already present if (!${{ steps.check-comment.outputs.hasReviewers }}) {
if (!inputs.hasReviewers) {
await github.rest.pulls.requestReviewers({ await github.rest.pulls.requestReviewers({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
pull_number: prNumber, pull_number: prNumber,
reviewers: ['@FredrikOseberg'], // Add your reviewers here reviewers: ['FredrikOseberg'], // Do not include @ in reviewer names
}); });
} }