Giter VIP home page Giter VIP logo

is-sponsor-label-action's Introduction

๐Ÿ’–

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: 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@v1
        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@v1
        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.

is-sponsor-label-action's People

Contributors

cheshire137 avatar devonzuegel avatar jasonetco avatar panva avatar wyrihaximus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

is-sponsor-label-action's Issues

Support custom Sponsorable users

Description

Some Projects are not sponsorable as an organization, but the individual maintainers are. It doesn't seem there is currently a way to customize which account the action should check for.

For example you can look at the PrismLibrary. This is a GitHub organizational account which isn't directly sponsorable. However both Brian and I are. I would love to be able to use this for Prism so that when anyone opens an issue or PR it could be labeled with the sponsor label if they sponsor either Brian or myself.

Action fails when PR is submitted from a fork

When a PR is submitted from a fork, the GitHub access token provided by ${{ secrets.GITHUB_TOKEN}} is downgraded to read-only. This causes the attempt to label the PR to fail:

Resource not accessible by integration

This has been discussed at actions/labeler#12.

The only workaround I've found is running the action from a scheduled workflow, as they started out to do in the actions/labeler action (actions/labeler@375fca6). However, as they realized, it's not so simple as just changing a couple lines in the workflow configuration. The action code likely needs significant reworking as well. I managed to get this working in an action that comments on PRs.

If you don't want to rework the action, the next best thing would be to document the limitation in the readme. Even if the action is limited to labeling issues, that's still very useful.

bug: Resource not accessible by integration

When we use JasonEtco/is-sponsor-label-action, we get this error:

Run JasonEtco/is-sponsor-label-action@v1
Error: Resource not accessible by integration
โœ–  fatal     GraphqlError: Resource not accessible by integration 
    at /home/runner/work/_actions/JasonEtco/is-sponsor-label-action/v1/dist/index.js:2463:13
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async makeRequest (/home/runner/work/_actions/JasonEtco/is-sponsor-label-action/v1/dist/index.js:150:20)
    at async Toolkit.run.event (/home/runner/work/_actions/JasonEtco/is-sponsor-label-action/v1/dist/index.js:20:21)

https://github.com/remirror/remirror/pull/1210/checks?check_run_id=3511169860

This action works pretty well the whole time and starts to show this error since yesterday.

Actions fails

With the following error:

  npm ERR! The `npm ci` command can only install with an existing package-lock.json or
  npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
  npm ERR! later to generate a package-lock.json file, then try again.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /root/.npm/_logs/2020-10-25T19_44_30_633Z-debug.log

Looking at the Dockerfile I guess it's because there is no nodejs version constraint?

action continues to fail

Error: Cannot read property 'id' of null
โœ–  fatal     TypeError: Cannot read property 'id' of null 
    at /lib/user-is-sponsor.js:45:41
    at Array.find (<anonymous>)
    at makeRequest (/lib/user-is-sponsor.js:45:15)

Screenshot 2020-11-15 at 13 27 25

I'd be happy to provide more details when requested.

Add support for pull_request_target

Hi @JasonEtco,

GITHUB_TOKEN secrets are not passed to the runner when a workflow is triggered from a forked repository so this action does not work for pull request unfortunately:

โฌค  debug     Making label [:sparkling_heart: sponsor]
โฌค  debug     Author is a sponsor! Adding the [:sparkling_heart: sponsor] label!
Error: Resource not accessible by integration
โœ–  fatal     HttpError: Resource not accessible by integration 
    at /home/runner/work/_actions/JasonEtco/is-sponsor-label-action/024ac24f8b170abce078cad4ee748852369853c8/dist/index.js:4602:23
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Toolkit.run.event (/home/runner/work/_actions/JasonEtco/is-sponsor-label-action/024ac24f8b170abce078cad4ee748852369853c8/dist/index.js:28:3)

So it would be nice to handle the pull_request_target event to be able to use this action in a PR from fork:

โœ–  error     Event `pull_request_target.reopened` is not supported by this action.

Thanks!

Organization Support

Hi, this is a lovely action.

Is it possible to adopt this to Organizations?

We have a public-repository on this Organization and have sponsors too. We would like to use this action on Organization repositories.

This lists the sponsors
{ organization(login: "doxa-labs") { sponsorshipsAsMaintainer(first: 100) { nodes { sponsor { id } } } } }

Sample organization:
https://github.com/doxa-labs

Also, which personal access token scopes are needed to add sponsor-label?

Thank you

Node.js 12 actions will be deprecated tomorrow

Using the v1.2.0 tagged version of JasonEtco/is-sponsor-label-action action, I get the following warning message:

Screenshot 2023-05-17 at 18 46 18
Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: JasonEtco/[email protected]. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

Node.js 12 actions are going to be deprecated tomorrow, May 18th.

Is there any plan to support Node.js 16? If so is there a plan to have a stable and tagged release of is-sponsor-label-action?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.