{"id":28940594,"url":"https://github.com/pgerke/promote-to-env","last_synced_at":"2025-09-02T06:33:25.501Z","repository":{"id":296229350,"uuid":"991827136","full_name":"pgerke/promote-to-env","owner":"pgerke","description":"A shell script that creates a branch promotion PR using the GitHub CLI","archived":false,"fork":false,"pushed_at":"2025-05-29T15:34:55.000Z","size":12,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-29T16:51:08.418Z","etag":null,"topics":["github-cli"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgerke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-28T07:54:50.000Z","updated_at":"2025-05-29T15:34:59.000Z","dependencies_parsed_at":"2025-05-29T17:06:22.494Z","dependency_job_id":null,"html_url":"https://github.com/pgerke/promote-to-env","commit_stats":null,"previous_names":["pgerke/promote-to-env"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pgerke/promote-to-env","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgerke%2Fpromote-to-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgerke%2Fpromote-to-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgerke%2Fpromote-to-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgerke%2Fpromote-to-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgerke","download_url":"https://codeload.github.com/pgerke/promote-to-env/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgerke%2Fpromote-to-env/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261396817,"owners_count":23152455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-cli"],"created_at":"2025-06-23T01:42:01.328Z","updated_at":"2025-09-02T06:33:25.472Z","avatar_url":"https://github.com/pgerke.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 promote-to-env.sh\n\nA shell script to automate merges between branches and create pull requests using the GitHub CLI (`gh`).\n\n## 🔧 Features\n\n- Creates a new branch `merge-to-\u003cTARGET_BRANCH\u003e` based on a target environment branch (e.g., `INT`)\n- Supports different merge strategies: `merge` (default), `rebase`, `ff` (fast-forward only)\n- Pushes the new branch and opens a **pull request**\n- Supports Markdown files or inline strings as PR body content\n- Automatically assigns the PR to the current authenticated user (`@me`)\n- Outputs the URL of the created PR\n- Supports optional override of remote name and local repo path – great for CI and automation\n- Supports `--dry-run` mode to simulate operations\n- Skips creating duplicate PRs if one already exists\n- Supports optional `--auto-merge` flag to auto-merge the PR after passing checks\n- Supports `--verbose` / `-v` flag to show detailed Git output (default: quiet)\n\n## 📦 Requirements\n\n- Git\n- [GitHub CLI](https://cli.github.com/) (`gh`) authenticated via `gh auth login`\n- Write access to the target repository\n\n## 🖥️ Usage\n\n```bash\n./promote-to-env.sh --target \u003cTARGET_BRANCH\u003e --source \u003cSOURCE_BRANCH\u003e \\\n  [--body-file FILE.md | --body \"Markdown text\"] \\\n  [--remote origin] [--merge-strategy merge] [--auto-merge] [--dry-run] [--verbose] [REPO_PATH]\n```\n\n### 🔤 Flags\n\n| Flag               | Description                                                     | Example                   |\n| ------------------ | --------------------------------------------------------------- | ------------------------- |\n| `--target`, `-t`   | Target branch for the PR (required)                             | `--target int`            |\n| `--source`, `-s`   | Source branch to merge (required)                               | `--source dev`            |\n| `--body-file`      | Optional: path to a Markdown file for the PR body               | `--body-file pr.md`       |\n| `--body`           | Optional: PR body string (ignored if `--body-file` is set)      | `--body \"text\"`           |\n| `--remote`         | Optional: Git remote (default: `origin`)                        | `--remote upstream`       |\n| `--merge-strategy` | Optional: `merge` (default), `rebase`, or `ff`                  | `--merge-strategy rebase` |\n| `--auto-merge`     | Optional: Auto-merge the PR once checks pass                    | `--auto-merge`            |\n| `--dry-run`        | Optional: Show what would happen without performing any changes | `--dry-run`               |\n| `--verbose`, `-v`  | Optional: Show verbose Git output                               | `--verbose`               |\n| `REPO_PATH`        | Optional: Path to local Git repo (as last positional argument)  | `./my-repo`               |\n\n## 📝 PR Body Template\n\nYou can use a Markdown file as the pull request body. The script replaces the placeholders `SOURCE_BRANCH` and `TARGET_BRANCH` automatically:\n\n```md\n## 🔀 Merge to TARGET_BRANCH\n\nThis pull request merges the latest changes from `SOURCE_BRANCH` into `TARGET_BRANCH`.\n\n### ✅ Context\n\nThis is part of our regular promotion pipeline.\n\n### 🚰 Details\n\n- Source branch: `SOURCE_BRANCH`\n- Target branch: `TARGET_BRANCH`\n- Merge strategy: default (merge)\n\n### 🙋‍♂️ Assignee\n\nAssigned to: @me\n```\n\n## 🔁 Example\n\n```bash\n./promote-to-env.sh -t int -s main --merge-strategy rebase --body-file .github/pr.md --auto-merge --verbose ./repo\n```\n\nThis will:\n\n- Create a branch `merge-to-int` off `origin/int`\n- Rebase `main` onto it\n- Push the new branch\n- Open a PR with the provided markdown as body\n- Assign it to the current user\n- Enable auto-merge if checks pass\n- Show Git command output\n- Output the PR URL\n\n## 🛉 Cleanup\n\nTemporary files used for template substitution are cleaned up automatically.\n\n## 💠 Extensions\n\nThis script can be easily extended to:\n\n- Add reviewers\n- Label or categorize PRs\n- GitHub Actions integration\n- Bash completion\n\n---\n\nMade with ❤️ by [Michaela Andermann](https://github.com/michix99) and [Philip Gerke](https://github.com/pgerke)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgerke%2Fpromote-to-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgerke%2Fpromote-to-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgerke%2Fpromote-to-env/lists"}