Skip to content

Commit

Permalink
gh actions job_id: use GITHUB_RUN_ID
Browse files Browse the repository at this point in the history
instead of GITHUB_ACTION which had values like __run_4 on
workflow_dispatch, and appears to have produced broken URLs in the
past.

refs manubot/rootstock#436 (comment)
  • Loading branch information
dhimmel committed Aug 25, 2021
1 parent ae50ec9 commit 9dd09ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions manubot/process/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_continuous_integration_parameters():
# https://git.io/JvUf7
repo_slug = os.environ["GITHUB_REPOSITORY"]
repo_owner, repo_name = repo_slug.split("/")
action_id = os.environ["GITHUB_ACTION"]
run_id = os.environ["GITHUB_RUN_ID"]
# GITHUB_SHA for pull_request event: Last merge commit on the GITHUB_REF branch
# GITHUB_SHA for push event: Commit pushed, unless deleting a branch (when it's the default branch)
# https://git.io/JvUfd
Expand All @@ -48,7 +48,7 @@ def get_continuous_integration_parameters():
"commit": github_sha,
"triggering_commit": os.getenv("GITHUB_PULL_REQUEST_SHA") or github_sha,
"build_url": f"https://github.com/{repo_slug}/commit/{github_sha}/checks",
"job_url": f"https://github.com/{repo_slug}/runs/{action_id}",
"job_url": f"https://github.com/{repo_slug}/actions/runs/{run_id}",
}
return ci_params

Expand Down
4 changes: 3 additions & 1 deletion manubot/process/tests/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def test_get_continuous_integration_parameters_github():
assert info["commit"]
assert info["triggering_commit"]
assert info["build_url"].startswith("https://github.com/manubot/manubot/commit/")
assert info["job_url"].startswith("https://github.com/manubot/manubot/runs/")
assert info["job_url"].startswith(
"https://github.com/manubot/manubot/actions/runs/"
)


@pytest.mark.skipif(
Expand Down

0 comments on commit 9dd09ad

Please sign in to comment.