|
1 | 1 | # Replace Hardcoded Owner/Repo References in CI Workflow |
2 | 2 |
|
3 | 3 | ## Goal |
4 | | -Replace hardcoded `cowwoc/cat` repository references in `.github/workflows/build-git-filter-repo.yml` |
5 | | -with GitHub Actions context variables (`github.repository_owner` and `github.event.repository.name`) |
6 | | -so the workflow is portable across forks and repository renames. |
| 4 | +Replace hardcoded `cowwoc/cat` repository references in `plugin/scripts/download-git-filter-repo.sh` |
| 5 | +with values read from `plugin/.git-filter-repo-config/release.conf`, so the download script is |
| 6 | +portable across forks and repository renames. |
7 | 7 |
|
8 | 8 | ## Background |
9 | | -The `build-git-filter-repo.yml` workflow contains hardcoded `cowwoc/cat` strings (e.g., in download |
10 | | -URL construction or artifact publishing steps). This prevents the workflow from working correctly in |
11 | | -forks or after a repository rename without manual edits. |
| 9 | +`plugin/scripts/download-git-filter-repo.sh` hardcodes `REPO_OWNER="cowwoc"` and `REPO_NAME="cat"` |
| 10 | +when constructing the GitHub release download URL. Investigation confirmed `.github/workflows/build-git-filter-repo.yml` |
| 11 | +does NOT contain hardcoded owner/repo references — it already uses GitHub Actions context variables correctly. |
| 12 | + |
| 13 | +The fix moves the owner/repo values into `release.conf` alongside the existing `RELEASE_TAG` and |
| 14 | +`PLATFORM_SHA256_*` fields, so forks that build their own binaries can update all release |
| 15 | +configuration in one place. |
| 16 | + |
| 17 | +## Research Findings |
| 18 | +- `.github/workflows/build-git-filter-repo.yml` uses `softprops/action-gh-release` which defaults to |
| 19 | + the current repository — no hardcoded owner/repo present, no changes needed. |
| 20 | +- `plugin/scripts/download-git-filter-repo.sh:174-175` has `REPO_OWNER="cowwoc"` and `REPO_NAME="cat"`. |
| 21 | +- `plugin/.git-filter-repo-config/release.conf` already contains `RELEASE_TAG` and `PLATFORM_SHA256_*` |
| 22 | + — the natural place to add `REPO_OWNER` and `REPO_NAME`. |
12 | 23 |
|
13 | 24 | ## Changes Required |
14 | 25 |
|
15 | | -1. Identify all occurrences of `cowwoc/cat` (or `cowwoc` alone) in |
16 | | - `.github/workflows/build-git-filter-repo.yml`. |
17 | | -2. Replace hardcoded owner with `${{ github.repository_owner }}`. |
18 | | -3. Replace hardcoded repo name with `${{ github.event.repository.name }}`. |
19 | | -4. Verify the replacement works for the artifact upload/download steps and any API calls. |
20 | | -5. Update `plugin/scripts/download-git-filter-repo.sh` if it also contains hardcoded owner/repo |
21 | | - references used for downloading release artifacts. |
| 26 | +### 1. `plugin/.git-filter-repo-config/release.conf` |
| 27 | + |
| 28 | +Add these fields immediately before `RELEASE_TAG`: |
| 29 | + |
| 30 | +```conf |
| 31 | +REPO_OWNER="cowwoc" |
| 32 | +REPO_NAME="cat" |
| 33 | +``` |
| 34 | + |
| 35 | +Update the "How to update" comment block (line ~13) to add: |
| 36 | +``` |
| 37 | +# 0. Update REPO_OWNER and REPO_NAME if building from a fork (optional for original repo). |
| 38 | +``` |
| 39 | + |
| 40 | +### 2. `plugin/scripts/download-git-filter-repo.sh` |
| 41 | + |
| 42 | +Remove these lines (~174-175): |
| 43 | +```bash |
| 44 | +REPO_OWNER="cowwoc" |
| 45 | +REPO_NAME="cat" |
| 46 | +``` |
| 47 | + |
| 48 | +Replace with parsing from `release.conf` (similar to the existing `RELEASE_TAG` parsing pattern): |
| 49 | +```bash |
| 50 | +REPO_OWNER=$(grep -E '^REPO_OWNER=' "${CONF}" | sed 's/^REPO_OWNER="\(.*\)"$/\1/' | head -1 || true) |
| 51 | +if [[ -z "${REPO_OWNER}" ]]; then |
| 52 | + echo "ERROR: REPO_OWNER not found in ${CONF}" >&2 |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | +if ! echo "${REPO_OWNER}" | grep -qE '^[a-zA-Z0-9_-]+$'; then |
| 56 | + echo "ERROR: REPO_OWNER in ${CONF} has unexpected format: ${REPO_OWNER}" >&2 |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | +REPO_NAME=$(grep -E '^REPO_NAME=' "${CONF}" | sed 's/^REPO_NAME="\(.*\)"$/\1/' | head -1 || true) |
| 60 | +if [[ -z "${REPO_NAME}" ]]; then |
| 61 | + echo "ERROR: REPO_NAME not found in ${CONF}" >&2 |
| 62 | + exit 1 |
| 63 | +fi |
| 64 | +if ! echo "${REPO_NAME}" | grep -qE '^[a-zA-Z0-9_-]+$'; then |
| 65 | + echo "ERROR: REPO_NAME in ${CONF} has unexpected format: ${REPO_NAME}" >&2 |
| 66 | + exit 1 |
| 67 | +fi |
| 68 | +``` |
22 | 69 |
|
23 | 70 | ## Post-conditions |
24 | 71 |
|
25 | | -- [ ] No hardcoded `cowwoc/cat` or `cowwoc` strings remain in the workflow or download script |
26 | | - (except in comments where explaining the original repository) |
27 | | -- [ ] The workflow uses GitHub Actions context variables for owner and repo name |
28 | | -- [ ] The workflow is tested in a fork to confirm portability |
29 | | -- [ ] No regressions introduced |
| 72 | +- [ ] No hardcoded `REPO_OWNER="cowwoc"` or `REPO_NAME="cat"` in `plugin/scripts/download-git-filter-repo.sh` |
| 73 | +- [ ] `plugin/.git-filter-repo-config/release.conf` contains `REPO_OWNER` and `REPO_NAME` fields |
| 74 | +- [ ] The download script reads `REPO_OWNER` and `REPO_NAME` from `release.conf` |
| 75 | +- [ ] Download script fails with a clear error when `REPO_OWNER` or `REPO_NAME` is missing or malformed |
| 76 | +- [ ] No regressions in `plugin/scripts/download-git-filter-repo.sh` functionality |
| 77 | + |
| 78 | +## Jobs |
| 79 | + |
| 80 | +### Job 1 |
| 81 | +- In `plugin/.git-filter-repo-config/release.conf`: add `REPO_OWNER="cowwoc"` and `REPO_NAME="cat"` fields before `RELEASE_TAG`, and add the step-0 note to the update comment block |
| 82 | +- In `plugin/scripts/download-git-filter-repo.sh`: remove hardcoded `REPO_OWNER` and `REPO_NAME` lines (~174-175) and add parsing code that reads them from `release.conf` using the same grep/sed pattern as `RELEASE_TAG` parsing, with fail-fast validation |
| 83 | +- Update `.cat/issues/v2/v2.1/replace-hardcoded-owner-repo-in-workflow/index.json` with `status: "closed"` and `progress: 100` |
| 84 | +- Commit type: `bugfix:` |
0 commit comments