From 4ddeb51b2fa9da6cbdbdbda68cfdc17094348ae0 Mon Sep 17 00:00:00 2001 From: Ben Du Date: Sun, 11 Jan 2026 13:58:32 -0800 Subject: [PATCH 1/2] update workflows --- .github/workflows/create_pr_dev_to_main.yml | 6 +++++- .github/workflows/create_pr_to_dev.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create_pr_dev_to_main.yml b/.github/workflows/create_pr_dev_to_main.yml index 310b6c8..e0cff26 100644 --- a/.github/workflows/create_pr_dev_to_main.yml +++ b/.github/workflows/create_pr_dev_to_main.yml @@ -13,5 +13,9 @@ jobs: - uses: actions/checkout@v6 - name: Create PR From dev To main run: | - .github/pr.py --head-branch dev --base-branch main --token ${{ secrets.GITHUBACTIONS }} + curl -sSL https://raw.githubusercontent.com/legendu-net/github_actions_scripts/main/create_pull_request.py \ + | uv run --script - \ + --head-branch dev \ + --base-branch main \ + --token ${{ secrets.GITHUBACTIONS }} diff --git a/.github/workflows/create_pr_to_dev.yml b/.github/workflows/create_pr_to_dev.yml index da4ebca..b792972 100644 --- a/.github/workflows/create_pr_to_dev.yml +++ b/.github/workflows/create_pr_to_dev.yml @@ -15,5 +15,9 @@ jobs: - uses: actions/checkout@v6 - name: Create PR to dev run: | - .github/pr.py --head-branch ${{ github.ref_name }} --base-branch dev --token ${{ secrets.GITHUBACTIONS }} + curl -sSL https://raw.githubusercontent.com/legendu-net/github_actions_scripts/main/create_pull_request.py \ + | uv run --script - \ + --head-branch ${{ github.ref_name }} \ + --base-branch dev \ + --token ${{ secrets.GITHUBACTIONS }} From e3a3ccdb16ebdc6ac0ed721ff633f468ea2cc47d Mon Sep 17 00:00:00 2001 From: Ben Du Date: Sun, 11 Jan 2026 14:01:55 -0800 Subject: [PATCH 2/2] update workflows --- .github/pr.py | 67 --------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100755 .github/pr.py diff --git a/.github/pr.py b/.github/pr.py deleted file mode 100755 index af1f049..0000000 --- a/.github/pr.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env -S uv run --script -# -# /// script -# requires-python = ">=3.12" -# dependencies = [ -# "github-rest-api>=0.25.0", -# ] -# /// - -"""Create a PR from the specified branch to dev. -The branch is updated (using dev) before creating the PR. -""" - -from argparse import ArgumentParser, Namespace -from github_rest_api import Repository - - -def parse_args(args=None, namespace=None) -> Namespace: - """Parse command-line arguments. - :param args: The arguments to parse. - If None, the arguments from command-line are parsed. - :param namespace: An inital Namespace object. - :return: A namespace object containing parsed options. - """ - parser = ArgumentParser(description="Create pull requests to the dev branch.") - parser.add_argument( - "--token", - dest="token", - required=True, - help="The personal access token for authentication.", - ) - parser.add_argument( - "--head-branch", - dest="head_branch", - required=True, - help="The head branch containing changes to merge.", - ) - parser.add_argument( - "--base-branch", - dest="base_branch", - required=True, - help="The base branch to merge changes into.", - ) - return parser.parse_args(args=args, namespace=namespace) - - -def main(): - """Main entrance of the script, - which creates a PR from the specified branch to dev. - The branch is updated (using dev) before creating the PR. - """ - args = parse_args() - # skip branches with the pattern _* - if args.head_branch.startswith("_"): - return - repo = Repository(args.token, "legendu-net/github_rest_api") - repo.create_pull_request( - { - "base": args.base_branch, - "head": args.head_branch, - "title": f"Merge {args.head_branch} Into {args.base_branch}", - }, - ) - - -if __name__ == "__main__": - main()