From 58a343c6081767217c3eb8f8310347578d179d60 Mon Sep 17 00:00:00 2001 From: Elio Di Nino <52972357+ElioDiNino@users.noreply.github.com> Date: Sat, 2 Mar 2024 08:32:53 -0500 Subject: [PATCH] Add ability to disable admin user check via flag (#559) * feat: add RH_ADMIN_CHECK flag * fix: correct env variable parsing and comparison * fix: don't add to cli options * ci: modify actions to add admin check input * fix: properly default to true --- .github/actions/check-release/action.yml | 7 +++++++ .github/actions/finalize-release/action.yml | 5 +++++ .github/actions/populate-release/action.yml | 5 +++++ .github/actions/prep-release/action.yml | 6 +++++- .github/actions/publish-changelog/action.yml | 5 +++++ jupyter_releaser/util.py | 2 +- 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/actions/check-release/action.yml b/.github/actions/check-release/action.yml index 1e1258ce..1eae9495 100644 --- a/.github/actions/check-release/action.yml +++ b/.github/actions/check-release/action.yml @@ -11,6 +11,10 @@ inputs: steps_to_skip: description: "Comma separated list of steps to skip" required: false + admin_check: + description: "Check if the user is a repo admin" + required: false + default: "true" shell: description: "The shell being used for the action steps" required: false @@ -31,6 +35,7 @@ runs: export GITHUB_ACCESS_TOKEN=${{ inputs.token }} export RH_VERSION_SPEC=${{ inputs.version_spec }} export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }} + export RH_ADMIN_CHECK=${{ inputs.admin_check }} python -m jupyter_releaser.actions.prep_release - id: populate-release @@ -40,6 +45,7 @@ runs: export GITHUB_ACCESS_TOKEN=${{ inputs.token }} export RH_RELEASE_URL=${{ steps.prep-release.outputs.release_url }} export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }} + export RH_ADMIN_CHECK=${{ inputs.admin_check }} export YARN_UNSAFE_HTTP_WHITELIST=0.0.0.0 python -m jupyter_releaser.actions.populate_release @@ -50,4 +56,5 @@ runs: export GITHUB_ACCESS_TOKEN=${{ inputs.token }} export RH_RELEASE_URL=${{ steps.populate-release.outputs.release_url }} export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }} + export RH_ADMIN_CHECK=${{ inputs.admin_check }} python -m jupyter_releaser.actions.finalize_release diff --git a/.github/actions/finalize-release/action.yml b/.github/actions/finalize-release/action.yml index a55d97ec..12a7422c 100644 --- a/.github/actions/finalize-release/action.yml +++ b/.github/actions/finalize-release/action.yml @@ -20,6 +20,10 @@ inputs: steps_to_skip: description: "Comma separated list of steps to skip" required: false + admin_check: + description: "Check if the user is a repo admin" + required: false + default: "true" shell: description: "The shell being used for the action steps" required: false @@ -52,6 +56,7 @@ runs: export RH_RELEASE_URL=${{ inputs.release_url }} export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }} export RH_BRANCH=${{ inputs.branch }} + export RH_ADMIN_CHECK=${{ inputs.admin_check }} python -m jupyter_releaser.actions.finalize_release - if: ${{ success() }} diff --git a/.github/actions/populate-release/action.yml b/.github/actions/populate-release/action.yml index 32c1499f..f185fa57 100644 --- a/.github/actions/populate-release/action.yml +++ b/.github/actions/populate-release/action.yml @@ -20,6 +20,10 @@ inputs: steps_to_skip: description: "Comma separated list of steps to skip" required: false + admin_check: + description: "Check if the user is a repo admin" + required: false + default: "true" shell: description: "The shell being used for the action steps" required: false @@ -49,6 +53,7 @@ runs: export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }} export RH_RELEASE_URL=${{ inputs.release_url }} export RH_BRANCH=${{ inputs.branch }} + export RH_ADMIN_CHECK=${{ inputs.admin_check }} python -m jupyter_releaser.actions.populate_release - if: ${{ failure() }} diff --git a/.github/actions/prep-release/action.yml b/.github/actions/prep-release/action.yml index 9770de20..ceb8a98f 100644 --- a/.github/actions/prep-release/action.yml +++ b/.github/actions/prep-release/action.yml @@ -24,13 +24,16 @@ inputs: silent: description: "Set a placeholder in the changelog and don't publish the release." required: false - type: boolean since: description: "Use PRs with activity since this date or git reference" required: false since_last_stable: description: "Use PRs with activity since the last stable git tag" required: false + admin_check: + description: "Check if the user is a repo admin" + required: false + default: "true" shell: description: "The shell being used for the action steps" required: false @@ -63,6 +66,7 @@ runs: export RH_SILENT=${{ inputs.silent }} export RH_SINCE=${{ inputs.since }} export RH_SINCE_LAST_STABLE=${{ inputs.since_last_stable }} + export RH_ADMIN_CHECK=${{ inputs.admin_check }} python -m jupyter_releaser.actions.prep_release diff --git a/.github/actions/publish-changelog/action.yml b/.github/actions/publish-changelog/action.yml index d6e42f0f..5023364f 100644 --- a/.github/actions/publish-changelog/action.yml +++ b/.github/actions/publish-changelog/action.yml @@ -14,6 +14,10 @@ inputs: description: "If set, do not make a PR" default: "false" required: false + admin_check: + description: "Check if the user is a repo admin" + required: false + default: "true" shell: description: "The shell being used for the action steps" required: false @@ -41,6 +45,7 @@ runs: export RH_BRANCH=${{ inputs.branch }} fi export RH_DRY_RUN=${{ inputs.dry_run }} + export RH_ADMIN_CHECK=${{ inputs.admin_check }} python -m jupyter_releaser.actions.publish_changelog diff --git a/jupyter_releaser/util.py b/jupyter_releaser/util.py index 56c2ffd4..464bdb5a 100644 --- a/jupyter_releaser/util.py +++ b/jupyter_releaser/util.py @@ -603,7 +603,7 @@ def prepare_environment(fetch_draft_release=True): gh = get_gh_object(dry_run=dry_run, owner=owner, repo=repo_name, token=auth) # Ensure the user is an admin. - if not dry_run: + if os.environ.get("RH_ADMIN_CHECK", "true").lower() == "true" and not dry_run: user = os.environ["GITHUB_ACTOR"] log(f"Getting permission level for {user}") try: