-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: fix HTTP PUT
request to the GitHub REST API
#1664
base: master
Are you sure you want to change the base?
ci: fix HTTP PUT
request to the GitHub REST API
#1664
Conversation
I tried nearly every option specified in the GitHub Docs, both with fine-grained and legacy tokens, but
The property The request itself successfully executes manually with header
so there is no mistake in it. @derberg, do you have ideas on what else could be researched? |
@aeworxet If it is working manually then there is some problem in the workflow itself. Could you try passing secrets.GH_TOKEN to github-token itself? You could try this endpoint as well https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#create-an-organization-invitation Also better would be to use their calls itself instead of raw API calls.https://octokit.github.io/rest.js/v21/#orgs-create-invitation |
MAINTAINERS.yaml
PUT
request to the GitHub REST API
@@ -94,15 +96,23 @@ jobs: | |||
- name: Invite new maintainers to the organization | |||
uses: actions/github-script@v6 | |||
with: | |||
github-token: ${{ env.GH_TOKEN }} | |||
github-token: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it just be
github-token: ${{ secrets.GITHUB_TOKEN }} | |
github-token: ${{ GITHUB_TOKEN }} |
cause you already have
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_TOKEN_ORG_ADMIN: ${{ secrets.GH_TOKEN_ORG_ADMIN }}
also GITHUB_TOKEN
doesn't exist but GH_TOKEN
and last but not least, why we pass different token and later have this in code
const ghTokenOrgAdmin = process.env.GH_TOKEN_ORG_ADMIN;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to https://github.com/actions/github-script/tree/v6.0.0?tab=readme-ov-file#using-a-separate-github-token if you pass token through github-token
config, the client inside the script is already using it
the best I suggest you take whole workflow and ask ChatGPT to analize - it is well trained to analize existing workflows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also GITHUB_TOKEN doesn't exist but GH_TOKEN
GITHUB_TOKEN
is a special random token that GitHub generates automatically on each workflow run, and with GH_TOKEN
, the step doesn't run at all.
shouldn't it just be
${{ GITHUB_TOKEN }}
You can use the GITHUB_TOKEN
by using the standard syntax for referencing secrets: ${{ secrets.GITHUB_TOKEN }}
.
https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
and last but not least, why we pass different token and later have this in code
I receive 401
regardless of the way it's written, but I set it directly to ${{ secrets.GH_TOKEN_ORG_ADMIN }}
; maybe this variant will work.
Review new version of code, please.
This PR attempts to fix the HTTP
PUT
request to the GitHub REST API.It is merged despite some uncertainty, as the necessary conditions can be met only in production environment.
Related to #1620