1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/.github/workflows/core-feature-alert.yml
Fredrik Strand Oseberg 7c646bc523
Chore/increase client api test coverage (#8950)
Added more tests around specific plans. Also added snapshot as per our
conversation @gastonfournier, but I'm unsure how much value it will give
because it seems that the tests should already catch this using
respondWithValidation and the OpenAPI schema. The problem here is that
empty array is a valid state, so there were no reason for the schema to
break the tests.
2024-12-12 11:42:18 +01:00

65 lines
2.4 KiB
YAML

name: Core Feature Alert
on:
pull_request:
types:
- opened
- synchronize
paths:
- src/lib/features/client-feature-toggles/**
- src/lib/features/frontend-api/**
jobs:
notify-core-changes:
runs-on: ubuntu-latest
steps:
- name: Fetch PR Creator's Username
id: pr-creator
run: echo "PR_CREATOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
- name: Post a notification about core feature changes if not already commented
uses: actions/github-script@v6
with:
script: |
const prCreator = process.env.PR_CREATOR;
const commentBody = `@${prCreator}, core features have been modified in this pull request. Please review carefully!`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
const alreadyCommented = comments.some(comment => comment.body === commentBody);
if (!alreadyCommented) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: commentBody,
});
console.log('Posted a new comment.');
} else {
console.log('Comment already exists, skipping.');
}
- name: Add reviewers to the PR if they are not the creator
uses: actions/github-script@v6
with:
script: |
const prCreator = process.env.PR_CREATOR;
const allReviewers = ['FredrikOseberg', 'gastonfournier', 'chriswk', 'ivarconr'];
const reviewersToAdd = allReviewers.filter(reviewer => reviewer !== prCreator);
if (reviewersToAdd.length > 0) {
github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
reviewers: reviewersToAdd,
});
console.log(`Added reviewers: ${reviewersToAdd.join(', ')}`);
} else {
console.log(`No reviewers to add as all match the PR creator.`);
}