|
| 1 | +# GitHub operations |
| 2 | + |
| 3 | +This repository uses GitHub CLI for pull request writes and GitHub Actions |
| 4 | +inspection. Use the repository entrypoint: |
| 5 | + |
| 6 | +```sh |
| 7 | +bin/gh |
| 8 | +``` |
| 9 | + |
| 10 | +Do not depend on `gh` being present in the shell `PATH`. Codex shells may omit |
| 11 | +Homebrew paths even though GitHub CLI is installed at `/opt/homebrew/bin/gh`. |
| 12 | +`bin/gh` resolves the installed binary and supports an explicit `GH_BIN` |
| 13 | +override. |
| 14 | + |
| 15 | +## Authentication and authorization |
| 16 | + |
| 17 | +Authentication is stored by GitHub CLI in the operating system credential |
| 18 | +store and survives new Codex sessions. Verify it before a GitHub operation: |
| 19 | + |
| 20 | +```sh |
| 21 | +bin/gh auth status |
| 22 | +bin/gh repo view --json nameWithOwner,viewerPermission |
| 23 | +``` |
| 24 | + |
| 25 | +The expected repository is `ciembor/polish-open-source`, and |
| 26 | +`viewerPermission` must be `WRITE`, `MAINTAIN`, or `ADMIN` for merge and branch |
| 27 | +write operations. |
| 28 | + |
| 29 | +If authentication is missing or its scopes are insufficient, authenticate the |
| 30 | +operator account once: |
| 31 | + |
| 32 | +```sh |
| 33 | +bin/gh auth login --hostname github.com --git-protocol ssh --web |
| 34 | +bin/gh auth refresh --hostname github.com --scopes repo,workflow,read:org |
| 35 | +``` |
| 36 | + |
| 37 | +Never copy or expose the GitHub CLI credential in repository files, |
| 38 | +`.env.local`, skill files, command arguments, or chat output. GitHub CLI owns |
| 39 | +its credential storage. The application's separately managed `GITHUB_TOKEN` in |
| 40 | +`.env.local` is runtime configuration and must not be reused as the CLI |
| 41 | +credential. |
| 42 | + |
| 43 | +GitHub network commands may require sandbox approval. Request persistent |
| 44 | +approval for the narrow `bin/gh` command prefix when the execution environment |
| 45 | +supports persisted command rules. |
| 46 | + |
| 47 | +## Pull request triage |
| 48 | + |
| 49 | +List all open pull requests, including Dependabot and human-authored changes: |
| 50 | + |
| 51 | +```sh |
| 52 | +bin/gh pr list --state open --limit 100 \ |
| 53 | + --json number,title,author,isDraft,updatedAt,url |
| 54 | +``` |
| 55 | + |
| 56 | +Dependabot pull requests have `author.login` equal to `dependabot[bot]`. Do not |
| 57 | +filter the initial list by author because other contributors and automation |
| 58 | +must remain visible. |
| 59 | + |
| 60 | +Inspect an individual pull request before changing it: |
| 61 | + |
| 62 | +```sh |
| 63 | +bin/gh pr view PR_NUMBER \ |
| 64 | + --json number,title,author,baseRefName,headRefName,isDraft,mergeable,mergeStateStatus,reviewDecision,statusCheckRollup,url |
| 65 | +bin/gh pr diff PR_NUMBER |
| 66 | +bin/gh pr checks PR_NUMBER |
| 67 | +``` |
| 68 | + |
| 69 | +For dependency updates, inspect the manifest and lockfile changes, the upstream |
| 70 | +release notes linked by Dependabot, and whether the update is major, minor, or |
| 71 | +patch. Treat major updates and security-relevant behavior changes as code |
| 72 | +changes requiring explicit compatibility review. Run the relevant local checks |
| 73 | +when the diff can affect runtime behavior. |
| 74 | + |
| 75 | +## Merge policy |
| 76 | + |
| 77 | +Merge only when the user requested that write action and all of these are true: |
| 78 | + |
| 79 | +- the pull request targets `master` and is not a draft; |
| 80 | +- the diff is understood and contains no unrelated or suspicious changes; |
| 81 | +- required reviews are satisfied; |
| 82 | +- required checks have completed successfully; |
| 83 | +- GitHub reports the pull request as mergeable and not blocked; |
| 84 | +- any update-specific local verification has passed. |
| 85 | + |
| 86 | +Use squash merge for this repository: |
| 87 | + |
| 88 | +```sh |
| 89 | +bin/gh pr merge PR_NUMBER --squash --delete-branch |
| 90 | +``` |
| 91 | + |
| 92 | +If branch protection requires queued or delayed merging, use: |
| 93 | + |
| 94 | +```sh |
| 95 | +bin/gh pr merge PR_NUMBER --squash --delete-branch --auto |
| 96 | +``` |
| 97 | + |
| 98 | +Do not bypass branch protection, use admin merge, dismiss reviews, or merge with |
| 99 | +failing or pending required checks unless the user explicitly requests the |
| 100 | +exception after the risk is stated. After merging, verify the resulting |
| 101 | +`master` workflow rather than assuming the pull request checks cover deploy. |
| 102 | + |
| 103 | +## GitHub Actions inspection |
| 104 | + |
| 105 | +Inspect pull request checks: |
| 106 | + |
| 107 | +```sh |
| 108 | +bin/gh pr checks PR_NUMBER |
| 109 | +``` |
| 110 | + |
| 111 | +Inspect recent runs on any branch: |
| 112 | + |
| 113 | +```sh |
| 114 | +bin/gh run list --workflow deploy.yml --limit 20 |
| 115 | +bin/gh run view RUN_ID |
| 116 | +bin/gh run view RUN_ID --log-failed |
| 117 | +``` |
| 118 | + |
| 119 | +The workflow is named `CI and deploy`. Its required pre-deploy jobs are |
| 120 | +`Quality`, `Dependency security`, `CodeQL`, and `Container smoke`; `Deploy` |
| 121 | +starts only after all four succeed. |
| 122 | + |
| 123 | +When CI fails: |
| 124 | + |
| 125 | +1. Read the failed job and step logs before editing. |
| 126 | +2. Decide whether the failure is caused by the pull request, infrastructure, or |
| 127 | + an unrelated flaky dependency. |
| 128 | +3. For a code failure, reproduce it with the narrowest local command, implement |
| 129 | + the fix, then run the relevant tests and `bin/quality`. |
| 130 | +4. Commit and push the fix without skipping pre-commit hooks. |
| 131 | +5. Recheck the pull request checks and report any remaining failure. |
| 132 | +6. Rerun a failed job only when the failure is demonstrably transient: |
| 133 | + |
| 134 | +```sh |
| 135 | +bin/gh run rerun RUN_ID --failed |
| 136 | +``` |
| 137 | + |
| 138 | +Do not rerun a deterministic code failure as a substitute for fixing it. |
| 139 | + |
| 140 | +## Manual workflow actions |
| 141 | + |
| 142 | +Normal deploys run after pushes to `master`. The documented one-step production |
| 143 | +rollback is the only routine manual workflow action: |
| 144 | + |
| 145 | +```sh |
| 146 | +bin/gh workflow run deploy.yml --ref master -f action=rollback |
| 147 | +``` |
| 148 | + |
| 149 | +Follow [Deployment](deployment.md) and |
| 150 | +[Operations Runbook](operations-runbook.md) before dispatching or evaluating a |
| 151 | +deploy or rollback. |
| 152 | + |
| 153 | +## Stable machine-readable output |
| 154 | + |
| 155 | +Prefer `--json` plus `--jq` for decisions and summaries. Avoid scraping |
| 156 | +human-formatted tables. Useful repository identity checks are: |
| 157 | + |
| 158 | +```sh |
| 159 | +bin/gh repo view --json nameWithOwner,defaultBranchRef,viewerPermission |
| 160 | +bin/gh api repos/ciembor/polish-open-source/branches/master/protection |
| 161 | +``` |
| 162 | + |
| 163 | +Branch protection can return `404` when it is not configured or when the |
| 164 | +authenticated account cannot read the setting. Distinguish those cases before |
| 165 | +making claims about merge requirements. |
0 commit comments