From 3926f13bba7cd19adb8c14d65ce67a0bd21f7ecb Mon Sep 17 00:00:00 2001 From: GameTec_live Date: Sat, 8 Feb 2025 18:06:51 +0100 Subject: [PATCH] fix: use github script for a reminder and only do it for first time contributors --- .github/workflows/changelog_reminder.yml | 43 ++++++++++++++++++------ 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/.github/workflows/changelog_reminder.yml b/.github/workflows/changelog_reminder.yml index b1cc0e0..39c33ba 100644 --- a/.github/workflows/changelog_reminder.yml +++ b/.github/workflows/changelog_reminder.yml @@ -1,15 +1,38 @@ on: pull_request_target name: Changelog Reminder + jobs: - remind: - name: Changelog Reminder + welcome: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - name: Changelog Reminder - uses: peterjgrainger/action-changelog-reminder@v1.2.0 - with: - changelog_regex: 'CHANGELOG.md' - customPrMessage: 'You are welcome to add an entry to the CHANGELOG.md as well' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/github-script@v7 + with: + script: | + // Get a list of all issues created by the PR opener + // See: https://octokit.github.io/rest.js/#pagination + const creator = context.payload.sender.login + const opts = octokit.rest.issues.listForRepo.endpoint.merge({ + ...context.issue, + creator, + state: 'all' + }) + const issues = await octokit.paginate(opts) + + for (const issue of issues) { + if (issue.number === context.issue.number) { + continue + } + + if (issue.pull_request) { + return // Creator is already a contributor. + } + } + + await octokit.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Reminder: + + You are welcome to add an entry to the [CHANGELOG.md](CHANGELOG.md) as well` + }) \ No newline at end of file