Files
freeCodeCamp/.github/workflows/welcome.yml
Naomi Carrigan fd62be8eb8 fix: workflow again (#46676)
* feat(tools): exclude known bot accounts

* feat(tools): pass in camperbot's token
2022-06-26 21:04:06 +02:00

50 lines
1.7 KiB
YAML

name: Github - Welcome First-timers
on:
pull_request:
types:
- closed
jobs:
welcome:
runs-on: ubuntu-latest
steps:
- name: Welcome New Contributors
if: github.event.pull_request.merged == true
uses: actions/github-script@7a5c598405937d486b0331594b5da2b14db670da # tag=v6
with:
github-token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }}
script: |
const pull = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const creator = pull.data.user.login;
const excludedCreators = ["renovate[bot]", "camperbot", "github-actions[bot]"];
if (excludedCreators.includes(creator)) {
return;
}
const repo = `${context.repo.owner}/${context.repo.repo}`;
const pulls = await github.rest.search.issuesAndPullRequests({
q: `repo:${repo}+author:${creator}+is:pr+is:merged`
});
// This means they've got merged PRs.
if (pulls?.data?.total_count > 1) {
return;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `
#### :sparkles: :tada: **AWESOME!** :tada: :sparkles:
Hi @${creator},
Thanks for this pull request and for contributing to the code-base for the first time. We are looking forward to more contributions from you in the future.
Cheers & happy contributing!
`
});