From 3518d15d50fac85300b3fd67b96d30e4cbbf57f4 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Mon, 3 Oct 2022 16:04:09 -0700 Subject: [PATCH] feat: spam automation (#47811) * fix(tools): invalid -> spam * feat: comment on spam * chore: job name Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> --- .github/workflows/autoclose.yml | 2 +- .github/workflows/spam.yml | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/spam.yml diff --git a/.github/workflows/autoclose.yml b/.github/workflows/autoclose.yml index e9fceda7c4d..c41908a3e95 100644 --- a/.github/workflows/autoclose.yml +++ b/.github/workflows/autoclose.yml @@ -46,6 +46,6 @@ jobs: owner: context.payload.repository.owner.login, repo: context.payload.repository.name, issue_number: context.issue.number, - labels: ["invalid"] + labels: ["spam"] }); } diff --git a/.github/workflows/spam.yml b/.github/workflows/spam.yml new file mode 100644 index 00000000000..9c4ff1be0bc --- /dev/null +++ b/.github/workflows/spam.yml @@ -0,0 +1,23 @@ +name: GitHub - Spam PR +on: + pull_request_target: + types: + - labeled + +jobs: + is-spam: + runs-on: ubuntu-20.04 + steps: + - uses: actions/github-script@7dff1a87643417cf3b95bb10b29f4c4bc60d8ebd # tag=v6 + with: + github-token: ${{secrets.CAMPERBOT_NO_TRANSLATE}} + script: | + const isSpam = context.payload.pull_request.labels.find(label => label.name === "spam"); + if (isSpam) { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "We are marking this pull request as spam. Please note that if you are participating in Hacktoberfest, two or more PRs marked as spam will result in your permanent disqualification.\n\nIf you are interested in making quality and genuine contributions to our projects, check out our [contributing guidelines](https://contribute.freecodecamp.org)." + }) + }