From 957a60d9a68714e0fcf8f0fdcf7c7a4789b8b296 Mon Sep 17 00:00:00 2001 From: FredrikOseberg Date: Mon, 9 Dec 2024 15:50:21 +0100 Subject: [PATCH] fix: revert changes --- .github/workflows/core-feature-alert.yml | 78 ++++++------------------ 1 file changed, 18 insertions(+), 60 deletions(-) diff --git a/.github/workflows/core-feature-alert.yml b/.github/workflows/core-feature-alert.yml index 8143d78710..095811143d 100644 --- a/.github/workflows/core-feature-alert.yml +++ b/.github/workflows/core-feature-alert.yml @@ -10,75 +10,33 @@ on: - src/lib/features/frontend-api/* jobs: - check-core-feature: + notify-core-changes: runs-on: ubuntu-latest steps: - - name: Checkout the repository - uses: actions/checkout@v3 + - name: Fetch PR Creator's Username + id: pr-creator + run: echo "PR_CREATOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV - - 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 + - name: Post a notification about core feature changes uses: actions/github-script@v6 with: script: | - const prNumber = context.payload.pull_request.number; - - // Check if a comment already exists - const comments = await github.rest.issues.listComments({ + const prCreator = process.env.PR_CREATOR; + github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: prNumber, - }); - - 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; - - core.setOutput('hasComment', hasComment); - core.setOutput('hasReviewers', hasReviewers); - - - name: Add reviewers and comment if necessary - if: steps.check-comment.outputs.hasComment == 'false' || steps.check-comment.outputs.hasReviewers == 'false' + issue_number: context.payload.pull_request.number, + body: `@${prCreator}, core features have been modified in this pull request. Please review!` + }) + - name: Add reviewers to the PR uses: actions/github-script@v6 with: script: | - const prNumber = context.payload.pull_request.number; - 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({ - 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 (!${{ steps.check-comment.outputs.hasReviewers }}) { - await github.rest.pulls.requestReviewers({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: prNumber, - reviewers: ['FredrikOseberg'], // Do not include @ in reviewer names - }); - } - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + const reviewers = ['FredrikOseberg']; + github.rest.pulls.requestReviewers({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + reviewers: reviewers, + }); \ No newline at end of file