diff --git a/.github/workflows/emeritus-check.yml b/.github/workflows/emeritus-check.yml new file mode 100644 index 0000000..abd7024 --- /dev/null +++ b/.github/workflows/emeritus-check.yml @@ -0,0 +1,38 @@ +name: Emeritus Check + +on: + # Run on the 1st of every month at 9:00 AM UTC + schedule: + - cron: "0 9 1 * *" + # Allow manual trigger + workflow_dispatch: + +permissions: + # Required to read repository contents + contents: read + # Required to create issues + issues: write + +jobs: + emeritus-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "24" + cache: "npm" + + - name: Install dependencies + run: npm i --ignore-scripts + + - name: Run emeritus check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: node index.js emeritus --monthsInactiveThreshold 12 --org fastify diff --git a/commands/emeritus.js b/commands/emeritus.js index 47480f7..32eaff3 100644 --- a/commands/emeritus.js +++ b/commands/emeritus.js @@ -48,18 +48,22 @@ export default async function emeritus ({ client, logger }, { org, monthsInactiv logger.info('[DRY-RUN] These users should be added to emeritus team:') usersToEmeritus.forEach(user => logger.info(`- @${user.user}`)) } else { - await client.createIssue( - orgData.name, - 'org-admin', - 'Move to emeritus members', + if (usersToEmeritus.length > 0) { + await client.createIssue( + orgData.name, + 'org-admin', + 'Move to emeritus members', `The following users have been inactive for more than ${monthsInactiveThreshold} months - and should be added to the emeritus team to control the access to the Fastify organization: + and should be added to the emeritus team to control the access to the Fastify organization + and secure the organization's repositories: ${usersToEmeritus.map(user => `- @${user.user}`).join('\n')} - \nComment here if you don't want to move them to emeritus team.`, + \nComment here if you don't want to be moved to emeritus team and confirm that your account + is still monitored and secured.`, ['question'] - ) + ) + } } }