From 4f1852bd97252a11408af052be2746685918a19f Mon Sep 17 00:00:00 2001 From: Katrina Owen Date: Fri, 25 Nov 2022 16:20:58 +0100 Subject: [PATCH 1/2] Create autoresponder for pausing community contributions We're going to take a step back and redesign the volunteering model for Exercism. Please see [this forum post](https://forum.exercism.org/t/freeing-our-maintainers-exercism-wide-changes-to-track-repositories/1109) for context. This PR adds an autoresponder that runs when an issue or PR is opened. If the person opening the issue is not a member of the Exercism organization, the autoresponder posts a comment and closes the issue. In the comment the author is directed to discuss the issue in the forum. If the discussion in the forum results in the issue/PR being approved, a maintainer or staff member will reopen it. Please feel free to merge this PR. It will be merged on December 1st, 2022. Please do not close it. If you wish to discuss this, please do so in [the forum post](https://forum.exercism.org/t/freeing-our-maintainers-exercism-wide-changes-to-track-repositories/1109) rather than here. --- .../pause-community-contributions.yml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/pause-community-contributions.yml diff --git a/.github/workflows/pause-community-contributions.yml b/.github/workflows/pause-community-contributions.yml new file mode 100644 index 000000000..add1280c4 --- /dev/null +++ b/.github/workflows/pause-community-contributions.yml @@ -0,0 +1,59 @@ +name: Pause Community Contributions + +on: + issues: + types: + - opened + pull_request_target: + types: + - opened + paths-ignore: + - "exercises/*/*/.approaches/**" + - "exercises/*/*/.articles/**" + workflow_dispatch: + +jobs: + pause: + name: Pause Community Contributions + runs-on: ubuntu-22.04 + steps: + - name: Detect if user is org member + uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 + id: is-organization-member + with: + script: | + if (context.actor == 'dependabot' || context.actor == 'exercism-bot' || context.actor == 'github-actions[bot]') { + return true; + } + + return github.rest.orgs.checkMembershipForUser({ + org: context.repo.owner, + username: context.actor, + }).then(response => response.status == 204) + .catch(err => true); + - name: Comment + if: steps.is-organization-member.outputs.result == 'false' + uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 + with: + script: | + const isIssue = !!context.payload.issue; + const subject = context.payload.issue || context.payload.pull_request; + const thing = (isIssue ? 'issue' : 'PR'); + const aThing = (isIssue ? 'an issue' : 'a PR'); + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Hello. Thanks for opening ${aThing} on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in [this blog post](https://exercism.org/blog/freeing-our-maintainers). **As such, all issues and PRs in this repository are being automatically closed.**\n\nThat doesn’t mean we’re not interested in your ideas, or that if you’re stuck on something we don’t want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use [this link](https://forum.exercism.org/new-topic?title=${encodeURI(subject.title)}&body=${encodeURI(subject.body)}&category=haskell) to copy this into a new topic there.\n\n---\n\n_Note: If this ${thing} has been pre-approved, please link back to this ${thing} on the forum thread and a maintainer or staff member will reopen it._\n` + }) + - name: Close + if: steps.is-organization-member.outputs.result == 'false' + uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 + with: + script: | + github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + state: "closed", + }) From d755227bad8d29219d83e252299f91fed926aaaf Mon Sep 17 00:00:00 2001 From: Katrina Owen Date: Wed, 30 Nov 2022 13:34:09 +0100 Subject: [PATCH 2/2] Update workflow for pausing community contributions This removes duplicated logic, relying on a shared workflow. --- .../pause-community-contributions.yml | 55 ++++--------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/.github/workflows/pause-community-contributions.yml b/.github/workflows/pause-community-contributions.yml index add1280c4..59fc784f8 100644 --- a/.github/workflows/pause-community-contributions.yml +++ b/.github/workflows/pause-community-contributions.yml @@ -8,52 +8,17 @@ on: types: - opened paths-ignore: - - "exercises/*/*/.approaches/**" - - "exercises/*/*/.articles/**" + - 'exercises/*/*/.approaches/**' + - 'exercises/*/*/.articles/**' workflow_dispatch: +permissions: + issues: write + pull-requests: write + jobs: pause: - name: Pause Community Contributions - runs-on: ubuntu-22.04 - steps: - - name: Detect if user is org member - uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 - id: is-organization-member - with: - script: | - if (context.actor == 'dependabot' || context.actor == 'exercism-bot' || context.actor == 'github-actions[bot]') { - return true; - } - - return github.rest.orgs.checkMembershipForUser({ - org: context.repo.owner, - username: context.actor, - }).then(response => response.status == 204) - .catch(err => true); - - name: Comment - if: steps.is-organization-member.outputs.result == 'false' - uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 - with: - script: | - const isIssue = !!context.payload.issue; - const subject = context.payload.issue || context.payload.pull_request; - const thing = (isIssue ? 'issue' : 'PR'); - const aThing = (isIssue ? 'an issue' : 'a PR'); - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `Hello. Thanks for opening ${aThing} on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in [this blog post](https://exercism.org/blog/freeing-our-maintainers). **As such, all issues and PRs in this repository are being automatically closed.**\n\nThat doesn’t mean we’re not interested in your ideas, or that if you’re stuck on something we don’t want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use [this link](https://forum.exercism.org/new-topic?title=${encodeURI(subject.title)}&body=${encodeURI(subject.body)}&category=haskell) to copy this into a new topic there.\n\n---\n\n_Note: If this ${thing} has been pre-approved, please link back to this ${thing} on the forum thread and a maintainer or staff member will reopen it._\n` - }) - - name: Close - if: steps.is-organization-member.outputs.result == 'false' - uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 - with: - script: | - github.rest.issues.update({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - state: "closed", - }) + if: github.repository_owner == 'exercism' # Stops this job from running on forks + uses: exercism/github-actions/.github/workflows/community-contributions.yml@main + with: + forum_category: haskell