Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
### UPDATED
- Readme instructions.

### FIXED
- Comment mistakenly removed when the owner comments on a repository that the organization owns.
  • Loading branch information
mrjackyliang committed Aug 15, 2024
1 parent 0747970 commit 5e3ed8a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Sponsor Gated Support
[![Become a GitHub Sponsor](https://img.shields.io/badge/github-sponsor-gray?style=flat-square&logo=githubsponsors&logoColor=%23ffffff&color=%23eaaf41)](https://github.com/sponsors/mrjackyliang)
[![Donate via PayPal](https://img.shields.io/badge/paypal-donate-gray?style=flat-square&logo=paypal&logoColor=%23ffffff&color=%23ce4a4a)](https://liang.nyc/paypal)

A GitHub Action designed to help project maintainers manage support requests (often referred to as "support tickets") in a way that encourages sponsorship and recognizes valuable contributors.
A GitHub Action designed to help project owners and contributors manage support requests (often referred to as "support tickets") in a way that it will encourage sponsorship and recognize valuable work.

This workflow helps limit users who have sponsored the project author or have been selected as an important contributor via an "exempt file" to be able to open issues.
In simple terms, this helps limit users who have sponsored the project author, appears as a contributor, or listed via an "exempt file" to be able to open issues.

_Originally, this workflow was not designed in mind to include bug reports and feature requests (in my opinion, those requests should be freely accessible), however, this action is configurable to the specific issue labels that you would like._

Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
- name: "Show current workflow directory"
run: "ls -la"
- name: "Check support issues"
uses: "mrjackyliang/[email protected].0"
uses: "mrjackyliang/[email protected].1"
with:
GITHUB_PERSONAL_ACCESS_TOKEN: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
GITHUB_WORKFLOW_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Expand All @@ -70,19 +70,19 @@ Here is a list of all the variables used in the action. It is __highly recommend
You may add variables to your repository via __Settings__ tab > __Security__ section > __Secrets and variables__ dropdown > __Actions__ item.
| Inputs | Workflow Variable | Description | Required | Accepts | Default |
|--------------------------------|--------------------------------|---------------------------------------------------------------------------------------------|----------|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `GITHUB_PERSONAL_ACCESS_TOKEN` | `PERSONAL_ACCESS_TOKEN` | Personal access token from GitHub used to fetch your sponsors | `true` | Token manually generated via the the [Personal Access Tokens (Classic)](https://github.com/settings/tokens) page | |
| `GITHUB_WORKFLOW_TOKEN` | `GITHUB_TOKEN` | Workflow token from GitHub used to perform issue and issue comment moderation | `true` | Token automatically generated on each workflow run | |
| `ISSUE_LABELS` | `ISSUE_LABELS` | Only set limits on issues with these labels (comma de-limited list) | `false` | Comma-delimited list of issue label names. For example, `support` or `support,amazing support` | `support` |
| `ISSUE_LIMIT_COMMENTER` | `ISSUE_LIMIT_COMMENTER` | Allow only the sponsoring user (that opened the issue) and contributor to comment on issues | `false` | `true` or `false` | `true` |
| `ISSUE_LOCK_ON_CLOSE` | `ISSUE_LOCK_ON_CLOSE` | Lock issues as soon as they become closed | `false` | `true` or `false` | `true` |
| `ISSUE_MESSAGE_NOT_SPONSOR` | `ISSUE_MESSAGE_NOT_SPONSOR` | Message to send when a non-sponsoring user opens an issue | `false` | A message for non-sponsors to sponsor you. | `Apologies! Only sponsoring users are allowed to open issues. Please sponsor the owner of this repository, then try again.` |
| `ISSUE_MESSAGE_WELCOME` | `ISSUE_MESSAGE_WELCOME` | Message to send when a sponsoring user opens an issue | `false` | A message for sponsors to thank them for sponsoring you. | `Thank you for your support! We appreciate your sponsorship and are here to help. We will review your issue and get back to you as soon as possible.` |
| `IS_ORGANIZATION` | `IS_ORGANIZATION` | If this workflow is being used on an organization-owned repository | `false` | `true` or `false` | `false` |
| `SPONSOR_ACTIVE_ONLY` | `SPONSOR_ACTIVE_ONLY` | Allow only active sponsoring users to open issues | `false` | `true` or `false` | `true` |
| `SPONSOR_EXEMPT_FILE_LOCATION` | `SPONSOR_EXEMPT_FILE_LOCATION` | A list of users that are exempt from sponsorship requirement | `false` | File path based on root (not workflow) project directory. For example, `./SPONSOR_EXEMPT` | `./SPONSOR_EXEMPT` |
| `SPONSOR_MINIMUM` | `SPONSOR_MINIMUM` | Allow only sponsoring users that reach this minimum amount (in cents) to open issues | `false` | A number displayed in cents. For example, $0.50 would be `50` and $10.00 would be `1000` | `0` |
| Inputs | Workflow Variable | Description | Required | Accepts | Default |
|--------------------------------|-------------------------------------|---------------------------------------------------------------------------------------------|----------|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `GITHUB_PERSONAL_ACCESS_TOKEN` | `secrets.PERSONAL_ACCESS_TOKEN` | Personal access token from GitHub used to fetch your sponsors | `true` | Token manually generated via the the [Personal Access Tokens (Classic)](https://github.com/settings/tokens) page | |
| `GITHUB_WORKFLOW_TOKEN` | `secrets.GITHUB_TOKEN` | Workflow token from GitHub used to perform issue and issue comment moderation | `true` | Token automatically generated on each workflow run | |
| `ISSUE_LABELS` | `vars.ISSUE_LABELS` | Only set limits on issues with these labels (comma de-limited list) | `false` | Comma-delimited list of issue label names. For example, `support` or `support,amazing support` | `support` |
| `ISSUE_LIMIT_COMMENTER` | `vars.ISSUE_LIMIT_COMMENTER` | Allow only the sponsoring user (that opened the issue) and contributor to comment on issues | `false` | `true` or `false` | `true` |
| `ISSUE_LOCK_ON_CLOSE` | `vars.ISSUE_LOCK_ON_CLOSE` | Lock issues as soon as they become closed | `false` | `true` or `false` | `true` |
| `ISSUE_MESSAGE_NOT_SPONSOR` | `vars.ISSUE_MESSAGE_NOT_SPONSOR` | Message to send when a non-sponsoring user opens an issue | `false` | A message for non-sponsors to sponsor you. | `Apologies! Only sponsoring users are allowed to open issues. Please sponsor the owner of this repository, then try again.` |
| `ISSUE_MESSAGE_WELCOME` | `vars.ISSUE_MESSAGE_WELCOME` | Message to send when a sponsoring user opens an issue | `false` | A message for sponsors to thank them for sponsoring you. | `Thank you for your support! We appreciate your sponsorship and are here to help. We will review your issue and get back to you as soon as possible.` |
| `IS_ORGANIZATION` | `vars.IS_ORGANIZATION` | If this workflow is being used on an organization-owned repository | `false` | `true` or `false` | `false` |
| `SPONSOR_ACTIVE_ONLY` | `vars.SPONSOR_ACTIVE_ONLY` | Allow only active sponsoring users to open issues | `false` | `true` or `false` | `true` |
| `SPONSOR_EXEMPT_FILE_LOCATION` | `vars.SPONSOR_EXEMPT_FILE_LOCATION` | A list of users that are exempt from sponsorship requirement | `false` | File path based on root (not workflow) project directory. For example, `./SPONSOR_EXEMPT` | `./SPONSOR_EXEMPT` |
| `SPONSOR_MINIMUM` | `vars.SPONSOR_MINIMUM` | Allow only sponsoring users that reach this minimum amount (in cents) to open issues | `false` | A number displayed in cents. For example, $0.50 would be `50` and $10.00 would be `1000` | `0` |

__Note:__ When you set your variables, please make sure to set the tokens under the __Secrets__ tab and all other related settings in the __Variables__ tab to ensure your secrets will not be accidentally exposed.

Expand Down
12 changes: 9 additions & 3 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53059,8 +53059,11 @@ async function issueCommentAction(payload, config) {
return;
}
if (data.comment.user.login === data.issue.user.login
|| data.comment.author_association === 'OWNER') {
core.info('Skipping "issue_comment" action, issue comment is made by either issue creator or owner');
|| data.comment.author_association === 'MEMBER'
|| data.comment.author_association === 'OWNER'
|| data.comment.author_association === 'CONTRIBUTOR'
|| data.comment.author_association === 'COLLABORATOR') {
core.info('Skipping "issue_comment" action, issue comment is made by either issue creator, member, owner, contributor, or collaborator');
core.setOutput('result', true);
return;
}
Expand Down Expand Up @@ -53104,7 +53107,10 @@ async function issuesAction(payload, config, sponsors) {
}
const { login } = data.issue.user;
if (sponsorsLogins.includes(login)
|| data.issue.author_association === 'OWNER') {
|| data.issue.author_association === 'MEMBER'
|| data.issue.author_association === 'OWNER'
|| data.issue.author_association === 'CONTRIBUTOR'
|| data.issue.author_association === 'COLLABORATOR') {
core.info('Adding issue comment based on "ISSUE_MESSAGE_WELCOME"');
await addIssueComment(data.issue.node_id, config.issueMessageWelcome, config);
}
Expand Down
2 changes: 1 addition & 1 deletion build/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sponsor-gated-support",
"displayName": "Sponsor Gated Support",
"version": "1.0.0",
"version": "1.0.1",
"description": "A GitHub Action designed to help project maintainers manage support requests in a way that encourages sponsorship and recognizes valuable contributors",
"main": "./build/index.js",
"exports": "./build/index.js",
Expand Down
12 changes: 9 additions & 3 deletions src/lib/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ export async function issueCommentAction(payload: IssueCommentActionPayload, con
return;
}

// Skip if comment ownership is the issue creator or owner.
// Skip if comment ownership is the issue creator, member, owner, contributor, or collaborator.
if (
data.comment.user.login === data.issue.user.login
|| data.comment.author_association === 'MEMBER'
|| data.comment.author_association === 'OWNER'
|| data.comment.author_association === 'CONTRIBUTOR'
|| data.comment.author_association === 'COLLABORATOR'
) {
core.info('Skipping "issue_comment" action, issue comment is made by either issue creator or owner');
core.info('Skipping "issue_comment" action, issue comment is made by either issue creator, member, owner, contributor, or collaborator');
core.setOutput('result', true);

return;
Expand Down Expand Up @@ -179,10 +182,13 @@ export async function issuesAction(payload: IssuesActionPayload, config: IssuesA

const { login } = data.issue.user;

// Check if the user is either sponsoring, in the exempt list, or is an owner.
// Check if the user is either sponsoring (including exempt list), a member, an owner, a contributor, or a collaborator.
if (
sponsorsLogins.includes(login)
|| data.issue.author_association === 'MEMBER'
|| data.issue.author_association === 'OWNER'
|| data.issue.author_association === 'CONTRIBUTOR'
|| data.issue.author_association === 'COLLABORATOR'
) {
core.info('Adding issue comment based on "ISSUE_MESSAGE_WELCOME"');
await addIssueComment(data.issue.node_id, config.issueMessageWelcome, config);
Expand Down

0 comments on commit 5e3ed8a

Please sign in to comment.