Skip to content

A GitHub Action designed to help project maintainers manage support requests in a way that encourages sponsorship and recognizes valuable contributors

License

Notifications You must be signed in to change notification settings

mrjackyliang/sponsor-gated-support

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Sponsor Gated Support

GitHub Releases GitHub Top Languages GitHub License Become a GitHub Sponsor Donate via PayPal

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.

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.

To use this action, here are three simple steps you need to follow:

  1. Add the action to your repository.
  2. Configure secrets and environment variables.
  3. Let the workflow automate issues!

Workflow Configuration

To create a workflow, simply copy and paste the block of text below to a file named sponsor-gated-support.yml and place it under the /.github/workflows directory.

Once you have done so, configure the variables by following the Workflow Variables section.

name: "Sponsor Gated Support"

run-name: "Running a task to analyze support issues"

on:
  issue_comment:
    types:
      - "created"
      - "edited"
  issues:
    types:
      - "opened"
      - "closed"

permissions:
  issues: "write"

jobs:
  check-issues:
    runs-on: "ubuntu-latest"
    steps:
      - name: "Checkout repository"
        uses: "actions/checkout@v4"
      - name: "Show current workflow directory"
        run: "ls -la"
      - name: "Check support issues"
        uses: "mrjackyliang/sponsor-gated-support@v1.0.1"
        with:
          GITHUB_PERSONAL_ACCESS_TOKEN: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
          GITHUB_WORKFLOW_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          ISSUE_LABELS: "${{ vars.ISSUE_LABELS }}"
          ISSUE_LIMIT_COMMENTER: "${{ vars.ISSUE_LIMIT_COMMENTER }}"
          ISSUE_LOCK_ON_CLOSE: "${{ vars.ISSUE_LOCK_ON_CLOSE }}"
          ISSUE_MESSAGE_NOT_SPONSOR: "${{ vars.ISSUE_MESSAGE_NOT_SPONSOR }}"
          ISSUE_MESSAGE_WELCOME: "${{ vars.ISSUE_MESSAGE_WELCOME }}"
          IS_ORGANIZATION: "${{ vars.IS_ORGANIZATION }}"
          SPONSOR_ACTIVE_ONLY: "${{ vars.SPONSOR_ACTIVE_ONLY }}"
          SPONSOR_EXEMPT_FILE_LOCATION: "${{ vars.SPONSOR_EXEMPT_FILE_LOCATION }}"
          SPONSOR_MINIMUM: "${{ vars.SPONSOR_MINIMUM }}"

Workflow Variables

Here is a list of all the variables used in the action. It is highly recommended that you set all available variables and not resort to the default values. Personalization is key!

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 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) 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.

Retrieve GitHub Personal Access Token

Unlike the automated token (secrets.GITHUB_TOKEN) that is randomly generated when a workflow is launched, a Personal Access Token (PAT) allows the action to retrieve active GitHub sponsors from your account.

  1. Login to GitHub, and visit the Personal Access Tokens (Classic) page.
  2. Click on the "Generate new token" dropdown, and select "Generate new token (classic)".
  3. On the "Note" field, type in "GitHub Action - Sponsor Gated Support".
  4. On the "Expiration" field, set it to "No expiration".
  5. On the "Select scopes" section, select "read:org" and "read:user" permissions.
  6. Select the "Generate token" button.
  7. Copy the token (starts with ghp_) and save it somewhere secure.
  8. Use this token in the GITHUB_PERSONAL_ACCESS_TOKEN workflow variable.

Note: This token should ONLY be assigned read-only permissions since making changes (e.g. adding or deleting comments) using this token will make it appear like you, and not the "github-actions" bot.

Note 2: If you are planning to use this action on an organization-owned repository, please make sure to set the "Allow access via personal access tokens (classic)" setting in the organization Settings tab > Third-party access section > Personal access tokens dropdown > Settings item.

Credits and Appreciation

If you find value in the ongoing development of this GitHub action and wish to express your appreciation, you can become my supporter on GitHub Sponsors!

About

A GitHub Action designed to help project maintainers manage support requests in a way that encourages sponsorship and recognizes valuable contributors

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published