💖🔖 A GitHub Action that labels issues/PRs if the creator is a sponsor of the owner
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Jason Etcovitch e54ba6b74c
Merge pull request #30 from cheshire137/main
4 months ago
.github/workflows Merge branch 'main' into publish-workflow 2 years ago
lib Also update JS usage 9 months ago
tests Fix an outdated test 4 months ago
.gitignore Init to winit 2 years ago
LICENSE Init to winit 2 years ago
README.md Remove "Point t" from the version 2 years ago
action.yml Setup build script 2 years ago
codecov.yml Add codecov YAML file 2 years ago
index.js Create the label manually 2 years ago
package-lock.json Various updoots 2 years ago
package.json Various updoots 2 years ago
screenshot.png Add a screenshot to README 2 years ago

README.md

💖

is-sponsor-label-action

A GitHub Action that labels issues/PRs if the creator is a sponsor of the owner

GitHub Actions status Codecov

Examples

Imagine Alice sponsors Bob through GitHub Sponsors, and Bob owns a public repo, which includes this sponsor-label action. Then, when Alice opens an issue or PR on that repo, a bot will automatically add a sponsor 💖 label.

Screenshot of an issue created by a sponsor, with the sponsor label added

You can see the above example here: https://github.com/devonzuegel/highly-exporter/issues/4

Usage

You can create a .github/workflows/label-sponsors.yml file:

name: Label sponsors
on:
  pull_request:
    types: [opened]
  issues:
    types: [opened]
jobs:
  build:
    name: is-sponsor-label
    runs-on: ubuntu-latest
    steps:
      - uses: JasonEtco/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This will trigger the action when an issue or pull request is opened. You'll need to include the GITHUB_TOKEN environment variable!

By default, the label sponsor will be applied. If you have a different label you want to use, you can set that:

      - uses: JasonEtco/[email protected]
        with:
          label: Sponsor Request ❤
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

How it works

This action is designed to be triggered by the issues or pull_request events, specifically the opened action. When an issue or PR is opened, the action will make the following query:

query ($owner: String!) { 
  user (login: $owner) {
    sponsorshipsAsMaintainer (first: 100) {
      nodes {
        sponsor {
          id
        }
      }
    }
  }
}

It will then check to see if the creator of the issue/PR is one of the sponsors in the list. If not, it'll try the next page of sponsors until it runs out.

Note! This query checks to see if the opener is a sponsor of the repository's owning user. This does not cover all cases of sponsorship!

If the opener is a sponsor, the action will then add the sponsor label to the issue or pull request.