Skip to content

Commit

Permalink
Get PR number from action
Browse files Browse the repository at this point in the history
  • Loading branch information
JordonPhillips committed Nov 20, 2024
1 parent 3a0e995 commit bf2bb7b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
6 changes: 2 additions & 4 deletions .changes/amend
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ def main() -> None:
parser.add_argument(
"-n",
"--pull-request-number",
help="""\
The numeric identifier for the pull request. This is provided by GitHub \
in the GITHUB_REF_NAME environment variable in the form \
'<pr_number>/merge'.""",
required=True,
help="The numeric identifier for the pull request.",
)
parser.add_argument(
"-r",
Expand Down
16 changes: 1 addition & 15 deletions .changes/tool/amend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,11 @@

def amend(
*,
pr_number: str | None = None,
pr_number: str,
repository: str | None = None,
base: str | None = None,
review_comment: bool = False,
) -> None:
if not pr_number:
pr_number = os.environ.get("GITHUB_REF_NAME")
if pr_number is None:
raise ValueError(
"""\
The pr number to amend onto entries MUST be set. This can be done as \
an argument to the command, or via the GITHUB_REF_NAME environment \
varaible as set by GitHub actions."""
)

# The GitHub environment variable is in the form "<pr_number>/merge", but
# we only want the pr number.
pr_number = pr_number.split("/")[0]

repository = repository or os.environ.get("GITHUB_REPOSITORY", DEFAULT_REPO)
pr_ref = f"[#{pr_number}]({GITHUB_URL}/{repository}/pull/{pr_number})"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/amend-new-changelogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
git fetch origin ${{ github.base_ref }}
./.changes/amend --review-comment
./.changes/amend --review-comment -n ${{ github.event.pull_request.number }}

0 comments on commit bf2bb7b

Please sign in to comment.