Skip to content

Releases: JasonEtco/is-sponsor-label-action

v2.0.0

21 May 21:53
565f3cb
Compare
Choose a tag to compare

This release includes a ton of dependency updates, hence the new major version just to be safe. Also drops support for the Node12 (which is now deprecated) runner, in favor of the Node16 runner.

v1.2.0

03 Mar 20:15
39d88e4
Compare
Choose a tag to compare

Fixes the underlying GraphQL request to no longer use a deprecated API - see #30 for more details! Thanks to @cheshire137 for the fix ✨

v1.1.3

17 Nov 21:22
024ac24
Compare
Choose a tag to compare

Fixes an edge-case where a sponsor node in the GraphQL response was null, thanks #17 @panva!

Also updates some dependencies.

v1.1.2

11 Nov 07:52
1183de2
Compare
Choose a tag to compare

What's new

v1.1.1

06 Mar 17:13
Compare
Choose a tag to compare

Fixes an issue with repeated use of the action when generating the label fails because it already exists. See #6 and #7 for more details!

v1.1.0

05 Mar 20:30
25fc2b7
Compare
Choose a tag to compare

Adds support for organization-owned repositories. Check out #5 for more details!

v1.0.0

04 Mar 19:23
Compare
Choose a tag to compare

Note: currently only works for user-owned repositories. This is due to a limitation of the GraphQL API, since we can't query for a "user or organization" in one request.

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: devonzuegel/highly-exporter#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/is-sponsor-label-action@master
        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/is-sponsor-label-action@master
        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.