Skip to content

Commit fb3e1f6

Browse files
committed
GH-47075: [Release][Dev] Use GH_TOKEN as GitHub token environment variable
We can still use `ARROW_GITHUB_API_TOKEN` and `CROSSBOW_GITHUB_TOKEN` for backward compatibility but `GH_TOKEN` is recommended.
1 parent bb33493 commit fb3e1f6

24 files changed

+89
-79
lines changed

.github/workflows/dev.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ jobs:
107107
gem install test-unit
108108
pip install "cython>=3" setuptools pytest requests setuptools-scm
109109
- name: Run Release Test
110-
env:
111-
ARROW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112110
shell: bash
113111
run: |
112+
echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" > dev/release/.env
114113
ci/scripts/release_test.sh $(pwd)
115114
- name: Run Merge Script Test
116115
shell: bash

.github/workflows/pr_bot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
run: pip install -e arrow/dev/archery[bot]
9090
- name: Handle PR workflow event
9191
env:
92-
ARROW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9393
run: |
9494
if [ "${GITHUB_EVENT_NAME}" = "workflow_run" ]; then
9595
# workflow_run is executed on PR review. Update to original event.

dev/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ for configuring your tokens: environment variables or a configuration file.
5656
#### Pass tokens via Environment Variables
5757

5858
The merge script uses the GitHub REST API. You must set a
59-
`ARROW_GITHUB_API_TOKEN` environment variable to use a
59+
`GH_TOKEN` environment variable to use a
6060
[Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
6161
You need to add `workflow` scope to the Personal Access Token.
6262

dev/archery/archery/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _clone_arrow_and_crossbow(dest, crossbow_repo, arrow_repo_url, pr_number):
359359
git.clone(crossbow_url, str(queue_path))
360360

361361
# 3. initialize crossbow objects
362-
github_token = os.environ['CROSSBOW_GITHUB_TOKEN']
362+
github_token = os.environ.get('GH_TOKEN', os.environ['CROSSBOW_GITHUB_TOKEN'])
363363
arrow = Repo(arrow_path)
364364
queue = Queue(queue_path, github_token=github_token, require_https=True)
365365

dev/archery/archery/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ def integration(with_all=False, random_seed=12345, **args):
815815

816816

817817
@archery.command()
818-
@click.option('--arrow-token', envvar='ARROW_GITHUB_TOKEN',
818+
@click.option('--arrow-token', envvar=['GH_TOKEN', 'ARROW_GITHUB_TOKEN'],
819819
help='OAuth token for responding comment in the arrow repo')
820820
@click.option('--committers-file', '-c', type=click.File('r', encoding='utf8'))
821821
@click.option('--event-name', '-n', required=True)

dev/archery/archery/crossbow/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
@click.group()
3737
@click.option('--github-token', '-t', default=None,
38-
envvar="CROSSBOW_GITHUB_TOKEN",
38+
envvar=['GH_TOKEN', 'CROSSBOW_GITHUB_TOKEN'],
3939
help='OAuth token for GitHub authentication')
4040
@click.option('--arrow-path', '-a',
4141
type=click.Path(), default=_default_arrow_path,

dev/archery/archery/crossbow/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def push(self, refs=None, github_token=None):
291291
if github_token is None:
292292
raise RuntimeError(
293293
'Could not determine GitHub token. Please set the '
294-
'CROSSBOW_GITHUB_TOKEN environment variable to a '
294+
'CROSSBOW_GITHUB_TOKEN or GH_TOKEN environment variable to a '
295295
'valid GitHub access token or pass one to --github-token.'
296296
)
297297
callbacks = GitRemoteCallbacks(github_token)

dev/archery/archery/release/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
callback=validate_arrow_sources,
2929
help="Specify Arrow source directory.")
3030
@click.option('--github-token', '-t', default=None,
31-
envvar="CROSSBOW_GITHUB_TOKEN",
31+
envvar=['GH_TOKEN', 'CROSSBOW_GITHUB_TOKEN'],
3232
help='OAuth token for GitHub authentication')
3333
@click.pass_obj
3434
def release(obj, src, github_token):

dev/merge_arrow_pr.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
# variables.
3131
#
3232
# Configuration environment variables:
33-
# - ARROW_GITHUB_API_TOKEN: a GitHub API token to use for API requests
33+
# - GH_TOKEN: a GitHub API token to use for API requests
34+
# - ARROW_GITHUB_API_TOKEN: Same as GH_TOKEN. For backward compatibility.
3435
# - ARROW_GITHUB_ORG: the GitHub organisation ('apache' by default)
3536
# - DEBUG: use for testing to avoid pushing to apache (0 by default)
3637

@@ -254,10 +255,13 @@ def __init__(self, project_name, cmd):
254255
config = load_configuration()
255256
if "github" in config.sections():
256257
token = config["github"]["api_token"]
258+
if not token:
259+
token = os.environ.get('GH_TOKEN')
257260
if not token:
258261
token = os.environ.get('ARROW_GITHUB_API_TOKEN')
259262
if not token:
260-
token = cmd.prompt('Env ARROW_GITHUB_API_TOKEN not set, '
263+
token = cmd.prompt('Env GH_TOKEN nor '
264+
'ARROW_GITHUB_API_TOKEN not set, '
261265
'please enter your GitHub API token '
262266
'(GitHub personal access token):')
263267
headers = {

dev/release/01-prepare-test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def setup
2828
Dir.mktmpdir do |dir|
2929
@test_git_repository = Pathname(dir) + "arrow"
3030
git("clone", @original_git_repository.to_s, @test_git_repository.to_s)
31+
FileUtils.cp((top_dir + "dev" + "release" + ".env").to_s,
32+
(@test_git_repository + "dev" + "release").to_s)
3133
Dir.chdir(@test_git_repository) do
3234
@release_branch = "testing-release-#{@release_version}-rc0"
3335
git("checkout", "-b", @release_branch, @current_commit)

0 commit comments

Comments
 (0)