Skip to content

Commit

Permalink
Rename parameter to make it clear it is a github token
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Oct 9, 2024
1 parent 44a2d59 commit c82f9c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cancel_workflows_for_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
scripts/tools/cancel_workflows_for_pr.py \
--pull-request ${{ inputs.pull_request_id }} \
--commit-sha "${{ inputs.commit_sha }}" \
--token "${{ secrets.GITHUB_TOKEN }}"
--gh-api-token "${{ secrets.GITHUB_TOKEN }}"
10 changes: 5 additions & 5 deletions scripts/tools/cancel_workflows_for_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ def cancel_all_runs(self, pr_number, commit_sha, dry_run):
)
@click.option("--pull-request", type=int, help="Pull request number to consider")
@click.option("--commit-sha", help="Commit to look at when cancelling pull requests")
@click.option("--token", help="Github token to use")
@click.option("--gh-api-token", help="Github token to use")
@click.option("--token-file", help="Read github token from the given file")
@click.option("--dry-run", default=False, is_flag=True, help="Actually cancel or not")
def main(log_level, pull_request, commit_sha, token, token_file, dry_run):
def main(log_level, pull_request, commit_sha, gh_api_token, token_file, dry_run):
coloredlogs.install(
level=__LOG_LEVELS__[log_level], fmt="%(asctime)s %(levelname)-7s %(message)s"
)

if token:
gh_token = token
if gh_api_token:
gh_token = gh_api_token
elif token_file:
gh_token = open(token_file, "rt").read().strip()
else:
raise Exception("Require a --token or --token-file to access github")
raise Exception("Require a --gh-api-token or --token-file to access github")

Canceller(gh_token).cancel_all_runs(pull_request, commit_sha, dry_run)

Expand Down

0 comments on commit c82f9c1

Please sign in to comment.