mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-03-29 15:30:52 -06:00
Some checks are pending
citra-build / source (push) Waiting to run
citra-build / linux (appimage) (push) Waiting to run
citra-build / linux (appimage-wayland) (push) Waiting to run
citra-build / linux (fresh) (push) Waiting to run
citra-build / macos (arm64) (push) Waiting to run
citra-build / macos (x86_64) (push) Waiting to run
citra-build / macos-universal (push) Blocked by required conditions
citra-build / windows (msvc) (push) Waiting to run
citra-build / windows (msys2) (push) Waiting to run
citra-build / android (googleplay) (push) Waiting to run
citra-build / android (vanilla) (push) Waiting to run
citra-build / docker (push) Waiting to run
citra-format / clang-format (push) Waiting to run
citra-transifex / transifex (push) Waiting to run
80 lines
2.8 KiB
YAML
80 lines
2.8 KiB
YAML
name: Verify first-time contributors
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
issues: write
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: ubuntu-latest
|
|
if: github.event.issue.pull_request && contains(github.event.issue.labels.*.name, 'needs verification')
|
|
steps:
|
|
- name: Verify and reopen PR
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const { owner, repo } = context.repo;
|
|
const issue = context.payload.issue;
|
|
const comment = context.payload.comment;
|
|
const { data: pr } = await github.rest.pulls.get({
|
|
owner,
|
|
repo,
|
|
pull_number: issue.number,
|
|
});
|
|
|
|
// Only allow verification of the comment user is the author
|
|
if (comment.user.login !== pr.user.login) {
|
|
return;
|
|
}
|
|
|
|
// Fetch user display and login names (lowercase)
|
|
const { data: user } = await github.rest.users.getByUsername({
|
|
username: pr.user.login,
|
|
});
|
|
const username = pr.user.login.toLowerCase();
|
|
const displayName = (user.name || '').toLowerCase();
|
|
|
|
// Make comment body lowercase and split words
|
|
const body = comment.body.toLowerCase().trim().replace(/[^a-z0-9_\-\s]/g, '').split(/\s+/);
|
|
|
|
// Check that the user verified themselves by writing a song about the NES and the SNES.
|
|
const verified =
|
|
(body.includes(username) ||
|
|
(displayName && body.includes(displayName))) &&
|
|
body.includes('azahar');
|
|
|
|
// Only reopen the PR and remove the label if verification succeeded
|
|
if (verified) {
|
|
await github.rest.pulls.update({
|
|
owner,
|
|
repo,
|
|
pull_number: issue.number,
|
|
state: 'open',
|
|
});
|
|
await github.rest.issues.createComment({
|
|
owner,
|
|
repo,
|
|
issue_number: issue.number,
|
|
body: 'Verification successful! Pull request has been reopened. Please also edit your PR description to remove the block of text between `---` to make the description easier to read.',
|
|
});
|
|
try {
|
|
await github.rest.issues.removeLabel({
|
|
owner,
|
|
repo,
|
|
issue_number: issue.number,
|
|
name: 'needs verification',
|
|
});
|
|
} catch {}
|
|
} else {
|
|
await github.rest.issues.createComment({
|
|
owner,
|
|
repo,
|
|
issue_number: issue.number,
|
|
body: 'Verification failed! Pull request will remain closed.',
|
|
});
|
|
}
|