mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
feat: alter logic
This commit is contained in:
parent
b73d459a2f
commit
e131ce6aed
78
.github/workflows/core-feature-alert.yml
vendored
78
.github/workflows/core-feature-alert.yml
vendored
@ -2,38 +2,80 @@ name: Core Feature Alert
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
paths:
|
paths:
|
||||||
- src/lib/features/client-feature-toggles/*
|
- src/lib/features/client-feature-toggles/*
|
||||||
- src/lib/features/frontend-api/*
|
- src/lib/features/frontend-api/*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
notify-core-changes:
|
check-core-feature:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch PR Creator's Username
|
- name: Checkout the repository
|
||||||
id: pr-creator
|
uses: actions/checkout@v3
|
||||||
run: echo "PR_CREATOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Post a notification about core feature changes
|
- name: Fetch PR details
|
||||||
|
id: pr-details
|
||||||
|
run: |
|
||||||
|
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
|
||||||
|
echo "PR_CREATOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Check if reviewers or comment already exist
|
||||||
|
id: check-comment
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const prCreator = process.env.PR_CREATOR;
|
const prNumber = context.payload.pull_request.number;
|
||||||
github.rest.issues.createComment({
|
|
||||||
|
// Check if a comment already exists
|
||||||
|
const comments = await github.rest.issues.listComments({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
issue_number: context.payload.pull_request.number,
|
issue_number: prNumber,
|
||||||
body: `@${prCreator}, core features have been modified in this pull request. Please review!`
|
});
|
||||||
})
|
|
||||||
- name: Add reviewers to the PR
|
const hasComment = comments.data.some(comment =>
|
||||||
|
comment.body.includes("Core features have been modified")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check if reviewers are already assigned
|
||||||
|
const reviewers = await github.rest.pulls.listRequestedReviewers({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
pull_number: prNumber,
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasReviewers = reviewers.data.users.length > 0;
|
||||||
|
|
||||||
|
return { hasComment, hasReviewers };
|
||||||
|
|
||||||
|
- 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 reviewers = ['FredrikOseberg'];
|
const prNumber = context.payload.pull_request.number;
|
||||||
github.rest.pulls.requestReviewers({
|
const prCreator = context.payload.pull_request.user.login;
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
// Add a comment if not already present
|
||||||
pull_number: context.payload.pull_request.number,
|
if (!inputs.hasComment) {
|
||||||
reviewers: reviewers,
|
await github.rest.issues.createComment({
|
||||||
});
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: prNumber,
|
||||||
|
body: `@${prCreator}, core features have been modified in this pull request. Reviewers have been added.`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add reviewers if not already present
|
||||||
|
if (!inputs.hasReviewers) {
|
||||||
|
await github.rest.pulls.requestReviewers({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
pull_number: prNumber,
|
||||||
|
reviewers: ['FredrikOseberg'], // Add your reviewers here
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user