Skip to content

Commit f47c2a9

Browse files
authored
chore: update search-repo-by-file.yaml
1 parent 6626fd1 commit f47c2a9

1 file changed

Lines changed: 22 additions & 32 deletions

File tree

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: search repos withiut file and set topic
1+
name: search repos without file and set topic
22
on:
33
workflow_dispatch:
44
inputs:
55
search_file:
66
default: .qubership/grand-report.json
77
type: string
88
temp_topic:
9-
default: grand-report-required
9+
default: grand-report-file-required
1010
type: string
1111

1212
jobs:
@@ -19,62 +19,52 @@ jobs:
1919
steps:
2020
- name: search
2121
run: |
22-
#!/bin/bash
23-
# =============================================
24-
# Скрипт: Добавление топика grand-report-required
25-
# Организация: Netcracker
26-
# Файл: .qubership/grand-report.json
27-
# =============================================
28-
2922
set -euo pipefail
3023
3124
ORG="${GITHUB_REPOSITORY_OWNER,,}"
3225
TOPIC="${{ inputs.temp_topic }}"
3326
FILE_PATH="${{ inputs.search_file }}"
3427
35-
echo "🔍 Получаем список всех неархивированных репозиториев $ORG..."
36-
37-
# Все репозитории (неархивированные)
28+
echo "🔍 Getting list of all not archived repositories in $ORG..."
3829
gh repo list "$ORG" --no-archived --limit 1000 --json nameWithOwner \
3930
| jq -r '.[].nameWithOwner' | sort > all_repos.txt
4031
41-
echo "Найдено репозиториев: $(wc -l < all_repos.txt)"
42-
43-
echo "🔎 Ищем репозитории, где есть файл $FILE_PATH..."
32+
echo "Found repositories: $(wc -l < all_repos.txt)"
4433
45-
# Репозитории, где файл присутствует (точный путь)
46-
# gh search code ".qubership/grand-report.json" --owner "$ORG" --match path
47-
gh search code ".qubership/grand-report.json" --owner "$ORG" --match path --limit 1000 --json repository \
34+
echo "🔎 Looking for repositories with file $FILE_PATH..."
35+
gh search code "${FILE_PATH}" --owner "$ORG" --match path --limit 1000 --json repository \
4836
| jq -r '.[].repository.nameWithOwner' | sort | uniq > repos_with_file.txt
4937
50-
echo "Репозиториев с файлом: $(wc -l < repos_with_file.txt)"
38+
echo "Repositories with file: $(wc -l < repos_with_file.txt)"
5139
52-
# Репозитории без файла
40+
# Repositories without file
5341
comm -23 all_repos.txt repos_with_file.txt > repos_without_file.txt
5442
5543
COUNT=$(wc -l < repos_without_file.txt)
56-
echo "✅ Найдено репозиториев БЕЗ файла: $COUNT"
44+
echo "✅ Found repositories without file: $COUNT"
5745
5846
if [ "$COUNT" -eq 0 ]; then
59-
echo "Все репозитории уже имеют файл. Ничего делать не нужно."
47+
echo "The file ${FILE_PATH} already present in all the repositories. Nothing to do."
6048
rm -f all_repos.txt repos_with_file.txt repos_without_file.txt
6149
exit 0
6250
fi
6351
64-
echo "🚀 Начинаем добавление топика '$TOPIC'..."
52+
echo "🚀 Starting to add topic '$TOPIC'..."
6553
6654
while IFS= read -r repo; do
67-
echo "Обработка $repo ... "
68-
echo "############### Добавляем топик"
69-
echo "gh repo edit \"$repo\" --add-topic \"$TOPIC\""
55+
echo "Working on $repo ... "
56+
# Check if topic already set
57+
CURRENT_TOPICS=$(gh repo view "$repo" --json repositoryTopics -q '.repositoryTopics[].name' 2>/dev/null || echo "")
58+
59+
if echo "$CURRENT_TOPICS" | grep -qw "$TOPIC"; then
60+
echo "уже имеет топик"
61+
continue
62+
fi
7063
# if gh repo edit "$repo" --add-topic "$TOPIC" >/dev/null 2>&1; then
71-
# echo "✅ топик добавлен"
64+
# echo "✅ topic added"
7265
# else
73-
# echo "❌ ошибка"
66+
# echo "❌ error"
7467
# fi
7568
done < repos_without_file.txt
7669
77-
echo "🎉 Готово! Топик '$TOPIC' добавлен во все нужные репозитории."
78-
79-
# Очистка временных файлов
80-
rm -f all_repos.txt repos_with_file.txt repos_without_file.txt
70+
echo "🎉 Done! Topic '$TOPIC' added to all target repositories."

0 commit comments

Comments
 (0)