Skip to content

Commit dee3036

Browse files
authored
Merge pull request #26 from Gfermoto/dev
fix: github-bootstrap-project — диагностика и вход с project scope
2 parents 3171fdb + e16dd1a commit dee3036

3 files changed

Lines changed: 49 additions & 13 deletions

File tree

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ Look for issues labelled **`good first issue`** — small, scoped tasks for newc
6464

6565
**Issues**, **Discussions**, and **Projects** are enabled on the repo. Labels `area:*`, `priority:*`, and `triage` support triage; milestones **v0.2.3** and **Backlog (no milestone)** are available.
6666

67-
To create the Kanban project **BirdLense Hub — Roadmap** and link this repository (requires GitHub CLI with `project` scope):
67+
To create the Kanban project **BirdLense Hub — Roadmap** and link this repository, GitHub CLI needs **Projects** scopes. If `gh auth refresh -s project -s read:project` does nothing, do a full login (or use a **classic** PAT with the `project` scope as `GH_TOKEN` — see script header):
6868

6969
```bash
70-
gh auth refresh -s project -s read:project
70+
gh auth logout -h github.com
71+
gh auth login -h github.com -w -s repo -s read:org -s gist -s project -s read:project
7172
bash scripts/github-bootstrap-project.sh
7273
```

CONTRIBUTING.ru.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ make start
6464

6565
В репозитории включены **Issues**, **Discussions** и **Projects**. Метки `area:*`, `priority:*`, `triage` и вехи **v0.2.3** / **Backlog (no milestone)** уже заведены.
6666

67-
Создать проект **BirdLense Hub — Roadmap**, привязать репозиторий и поле «Поток» (канбан):
67+
Создать проект **BirdLense Hub — Roadmap**, привязать репозиторий и поле «Поток» (канбан). Нужны права **Projects** у токена gh. Если `gh auth refresh` не помогает — полный вход или classic PAT с scope `project` (см. комментарии в `scripts/github-bootstrap-project.sh`):
6868

6969
```bash
70-
gh auth refresh -s project -s read:project
70+
gh auth logout -h github.com
71+
gh auth login -h github.com -w -s repo -s read:org -s gist -s project -s read:project
7172
bash scripts/github-bootstrap-project.sh
7273
```

scripts/github-bootstrap-project.sh

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,56 @@
11
#!/usr/bin/env bash
22
# Создаёт GitHub Project (v2) у владельца, линкует репозиторий BirdLense-Hub,
3-
# добавляет поле «Поток» (Backlog → … → Done) поверх стандартного Status.
3+
# добавляет поле «Поток» (Backlog → … → Done).
44
#
5-
# Требуется один раз расширить gh-токен:
6-
# gh auth refresh -s project -s read:project
5+
# Аутентификация (любой рабочий вариант):
6+
#
7+
# A) OAuth через браузер с нужными scope (надёжнее, чем только refresh):
8+
# gh auth logout -h github.com
9+
# gh auth login -h github.com -w -s repo -s read:org -s gist -s project -s read:project
10+
#
11+
# B) Классический PAT: https://github.com/settings/tokens/new
12+
# Включите scope «project» (и «repo», «read:org» как минимум).
13+
# export GH_TOKEN=ghp_xxxxxxxx
14+
# bash scripts/github-bootstrap-project.sh
15+
#
16+
# Вариант «refresh» часто НЕ добавляет project, если токен fine-grained или кэш не обновился.
717
#
818
set -euo pipefail
919

1020
OWNER="${GITHUB_PROJECT_OWNER:-Gfermoto}"
1121
REPO_FULL="${GITHUB_REPO:-Gfermoto/BirdLense-Hub}"
1222
PROJECT_TITLE="${GITHUB_PROJECT_TITLE:-BirdLense Hub — Roadmap}"
1323

14-
if ! gh project list --owner "$OWNER" --limit 1 >/dev/null 2>&1; then
15-
echo "gh не может читать Projects (нужны scope project / read:project). Выполните:"
16-
echo " gh auth refresh -s project -s read:project"
17-
echo "Затем снова запустите этот скрипт."
24+
die_help() {
25+
echo ""
26+
echo "=== Что сделать ==="
27+
echo "1) Посмотрите scopes: gh auth status"
28+
echo " Нужны в списке: project и read:project (или один classic PAT с правом Projects)."
29+
echo ""
30+
echo "2) Надёжно: полный вход с scope:"
31+
echo " gh auth logout -h github.com"
32+
echo " gh auth login -h github.com -w -s repo -s read:org -s gist -s project -s read:project"
33+
echo ""
34+
echo "3) Или classic PAT в переменную (не коммитьте!):"
35+
echo " export GH_TOKEN=ghp_..."
36+
echo " bash scripts/github-bootstrap-project.sh"
37+
echo ""
1838
exit 1
39+
}
40+
41+
TMPERR=$(mktemp)
42+
trap 'rm -f "$TMPERR"' EXIT
43+
44+
if ! gh project list --owner "$OWNER" --limit 1 2>"$TMPERR"; then
45+
echo "Ошибка при gh project list:"
46+
sed 's/^/ /' "$TMPERR"
47+
echo ""
48+
if [[ -n "${GH_TOKEN:-}" ]]; then
49+
echo "Используется GH_TOKEN: убедитесь, что это классический PAT со scope «project» (fine-grained с ограничением только на репо Projects может не подойти)."
50+
else
51+
echo "Токен gh, скорее всего, без scope Projects. «gh auth refresh» иногда не меняет права (fine-grained / старый OAuth)."
52+
fi
53+
die_help
1954
fi
2055

2156
exists_json=$(gh project list --owner "$OWNER" --format json --limit 50)
@@ -33,8 +68,7 @@ fi
3368
echo "Линкую $REPO_FULL"
3469
gh project link "$proj_num" --owner "$OWNER" --repo "$REPO_FULL" 2>/dev/null || true
3570

36-
# Доп. поле для канбана (рядом со стандартным полем Status в Projects)
37-
echo "Добавляю поле «Поток» (если ещё нет — при дубликате будет ошибка, её можно игнорировать)…"
71+
echo "Добавляю поле «Поток» (если ещё нет — при дубликате можно игнорировать)…"
3872
gh project field-create "$proj_num" --owner "$OWNER" \
3973
--name "Поток" \
4074
--data-type "SINGLE_SELECT" \

0 commit comments

Comments
 (0)