|
| 1 | +name: Pause Community Contributions |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + pull_request_target: |
| 8 | + types: |
| 9 | + - opened |
| 10 | + paths-ignore: |
| 11 | + - 'exercises/*/*/.approaches/**' |
| 12 | + - 'exercises/*/*/.articles/**' |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + pause: |
| 17 | + name: Pause Community Contributions |
| 18 | + runs-on: ubuntu-22.04 |
| 19 | + steps: |
| 20 | + - name: Detect if user is org member |
| 21 | + uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 |
| 22 | + id: is-organization-member |
| 23 | + with: |
| 24 | + script: | |
| 25 | + if (context.actor == 'dependabot' || context.actor == 'exercism-bot' || context.actor == 'github-actions[bot]') { |
| 26 | + return true; |
| 27 | + } |
| 28 | +
|
| 29 | + return github.rest.orgs.checkMembershipForUser({ |
| 30 | + org: context.repo.owner, |
| 31 | + username: context.actor, |
| 32 | + }).then(response => response.status == 204) |
| 33 | + .catch(err => true); |
| 34 | + - name: Comment |
| 35 | + if: steps.is-organization-member.outputs.result == 'false' |
| 36 | + uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 |
| 37 | + with: |
| 38 | + script: | |
| 39 | + const isIssue = !!context.payload.issue; |
| 40 | + const subject = context.payload.issue || context.payload.pull_request; |
| 41 | + const thing = (isIssue ? 'issue' : 'PR'); |
| 42 | + const aThing = (isIssue ? 'an issue' : 'a PR'); |
| 43 | + github.rest.issues.createComment({ |
| 44 | + issue_number: context.issue.number, |
| 45 | + owner: context.repo.owner, |
| 46 | + repo: context.repo.repo, |
| 47 | + 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=ruby) 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` |
| 48 | + }) |
| 49 | + - name: Close |
| 50 | + if: steps.is-organization-member.outputs.result == 'false' |
| 51 | + uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 |
| 52 | + with: |
| 53 | + script: | |
| 54 | + github.rest.issues.update({ |
| 55 | + owner: context.repo.owner, |
| 56 | + repo: context.repo.repo, |
| 57 | + issue_number: context.issue.number, |
| 58 | + state: 'closed', |
| 59 | + }) |
0 commit comments