Skip to content

Commit

Permalink
Add ability to disable admin user check via flag (#559)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ElioDiNino authored Mar 2, 2024
1 parent f26f919 commit 58a343c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/actions/check-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
5 changes: 5 additions & 0 deletions .github/actions/finalize-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() }}
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/populate-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() }}
Expand Down
6 changes: 5 additions & 1 deletion .github/actions/prep-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/publish-changelog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 58a343c

Please sign in to comment.