Git Product home page Git Product logo

Comments (6)

gautamkrishnar avatar gautamkrishnar commented on June 12, 2024 1

@lgmorand, it looks like there is an even simpler way to detect branch protection just by using process.env.GITHUB_REF_PROTECTED === 'true'

But this won't still fix the token permission issue though. We still need to use the token permission API to determine if the token provided has write access to the repo. But adding branch protection check is the first step.

from keepalive-workflow.

lgmorand avatar lgmorand commented on June 12, 2024 1

indeed. Branch protection is something you can't do much. but helping to understand that token doesn't have enough rights could be useful

from keepalive-workflow.

gautamkrishnar avatar gautamkrishnar commented on June 12, 2024

it looks like github api do not support it right now:

curl -sS -f -H "Authorization: token <token>" https://api.github.com/repos/example-user/example-repo  | jq .permissions
{
  "admin": false,
  "maintain": false,
  "push": false,
  "triage": false,
  "pull": false
}

This is the response we always get.

there are other users who also have same problem: https://github.com/orgs/community/discussions/25259

Created new bug report here: https://github.com/orgs/community/discussions/73397

from keepalive-workflow.

lgmorand avatar lgmorand commented on June 12, 2024

maybe you could just check the current branch status because token scope won't help in any case I think

https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection

It would report if the current branch is protected or not. if yes, add a warning/exit

from keepalive-workflow.

gautamkrishnar avatar gautamkrishnar commented on June 12, 2024

@lgmorand thanks a lot for the suggestion. This looks like a great option. Will give it a try. Never knew that this API existed before 😄

from keepalive-workflow.

Related Issues (8)

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.