[llvm] [workflows] Fix permissions check for creating new releases (PR #81163)
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 09:42:08 PST 2024
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/81163
The default GitHub token does not have read permissions on the org, so we need to use a custom token in order to read the members of the llvm-release-managers team.
>From e7eaed8d0b9145ec89e05863f2272932cbaf8ce5 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Thu, 8 Feb 2024 09:40:23 -0800
Subject: [PATCH] [workflows] Fix permissions check for creating new releases
The default GitHub token does not have read permissions on the org, so
we need to use a custom token in order to read the members of the
llvm-release-managers team.
---
.github/workflows/release-tasks.yml | 4 +++-
llvm/utils/release/github-upload-release.py | 11 +++++++----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/release-tasks.yml b/.github/workflows/release-tasks.yml
index f2a831ad3577a..53da8662b0203 100644
--- a/.github/workflows/release-tasks.yml
+++ b/.github/workflows/release-tasks.yml
@@ -28,6 +28,7 @@ jobs:
name: Create a New Release
runs-on: ubuntu-latest
needs: validate-tag
+
steps:
- name: Install Dependencies
run: |
@@ -40,8 +41,9 @@ jobs:
- name: Create Release
env:
GITHUB_TOKEN: ${{ github.token }}
+ USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
run: |
- ./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} create
+ ./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} --user-token "$USER_TOKEN" create
release-documentation:
name: Build and Upload Release Documentation
needs:
diff --git a/llvm/utils/release/github-upload-release.py b/llvm/utils/release/github-upload-release.py
index a8bb569d2fc99..5115e5082fb2c 100755
--- a/llvm/utils/release/github-upload-release.py
+++ b/llvm/utils/release/github-upload-release.py
@@ -77,20 +77,23 @@ def upload_files(repo, release, files):
parser.add_argument("--token", type=str)
parser.add_argument("--release", type=str)
parser.add_argument("--user", type=str)
+parser.add_argument("--user-token", type=str)
# Upload args
parser.add_argument("--files", nargs="+", type=str)
args = parser.parse_args()
-github = github.Github(args.token)
-llvm_org = github.get_organization("llvm")
+gh = github.Github(args.token)
+llvm_org = gh.get_organization("llvm")
llvm_repo = llvm_org.get_repo("llvm-project")
+if not args.user_token:
+ args.user_token = args.token
if args.user:
# Validate that this user is allowed to modify releases.
- user = github.get_user(args.user)
- team = llvm_org.get_team_by_slug("llvm-release-managers")
+ user = gh.get_user(args.user)
+ team = github.Github(args.user_token).get_organization("llvm").get_team_by_slug("llvm-release-managers")
if not team.has_in_members(user):
print("User {} is not a allowed to modify releases".format(args.user))
sys.exit(1)
More information about the llvm-commits
mailing list