Skip to content

Commit 230cebb

Browse files
authored
feat: added workflows to set and remove topic and broadcast grand-report.json file configuration
Netcracker/qubership-workflow-hub#691
1 parent f47c2a9 commit 230cebb

4 files changed

Lines changed: 67 additions & 17 deletions

File tree

.github/broadcast-files-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,11 @@ test_pipes_update:
219219
commit_message: |
220220
feat(ci): added new workflow to bump test-workflows version
221221
related issue https://github.com/Netcracker/qubership-workflow-hub/issues/682
222+
grand_report_json:
223+
topics_to_include: grand-report-file-required
224+
patterns_to_include: config/examples/grand-report.json
225+
destination: .qubership
226+
bot_branch_name: broadcast-cgrand-report-json
227+
commit_message: |
228+
chore: added empty .qubership/grand-report.json file
229+
related issue: https://github.com/Netcracker/qubership-workflow-hub/issues/691
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Remove topic from repositories
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
topic:
6+
description: "Topic name to remove"
7+
required: true
8+
type: string
9+
permissions:
10+
contents: read
11+
jobs:
12+
remove-topic:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
env:
17+
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
18+
steps:
19+
- name: Remove topic
20+
run: |
21+
ORG="${GITHUB_REPOSITORY_OWNER,,}"
22+
TOPIC="${{ inputs.topic }}"
23+
24+
echo "🔍 Getting list of all not archived repositories in $ORG..."
25+
gh repo list "$ORG" --no-archived --limit 1000 --json nameWithOwner \
26+
| jq -r '.[].nameWithOwner' | sort > all_repos.txt
27+
echo "Found repositories: $(wc -l < all_repos.txt)"
28+
echo "🚀 Starting to delete topic '$TOPIC'..."
29+
30+
while IFS= read -r repo; do
31+
echo "Working on $repo ... "
32+
# Check if topic set on repository
33+
CURRENT_TOPICS=$(gh repo view "$repo" --json repositoryTopics -q '.repositoryTopics[].name' 2>/dev/null || echo "")
34+
35+
if echo "$CURRENT_TOPICS" | grep -qw "$TOPIC"; then
36+
echo "Topic found. Removing it ..."
37+
gh repo edit "$repo" --remove-topic "$TOPIC"
38+
fi
39+
done < all_repos.txt

.github/workflows/search-repo-by-file.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,51 @@ jobs:
2020
- name: search
2121
run: |
2222
set -euo pipefail
23-
23+
2424
ORG="${GITHUB_REPOSITORY_OWNER,,}"
2525
TOPIC="${{ inputs.temp_topic }}"
2626
FILE_PATH="${{ inputs.search_file }}"
27-
27+
2828
echo "🔍 Getting list of all not archived repositories in $ORG..."
2929
gh repo list "$ORG" --no-archived --limit 1000 --json nameWithOwner \
3030
| jq -r '.[].nameWithOwner' | sort > all_repos.txt
31-
31+
3232
echo "Found repositories: $(wc -l < all_repos.txt)"
33-
33+
3434
echo "🔎 Looking for repositories with file $FILE_PATH..."
3535
gh search code "${FILE_PATH}" --owner "$ORG" --match path --limit 1000 --json repository \
3636
| jq -r '.[].repository.nameWithOwner' | sort | uniq > repos_with_file.txt
37-
37+
3838
echo "Repositories with file: $(wc -l < repos_with_file.txt)"
39-
39+
4040
# Repositories without file
4141
comm -23 all_repos.txt repos_with_file.txt > repos_without_file.txt
42-
42+
4343
COUNT=$(wc -l < repos_without_file.txt)
4444
echo "✅ Found repositories without file: $COUNT"
45-
45+
4646
if [ "$COUNT" -eq 0 ]; then
4747
echo "The file ${FILE_PATH} already present in all the repositories. Nothing to do."
4848
rm -f all_repos.txt repos_with_file.txt repos_without_file.txt
4949
exit 0
5050
fi
51-
51+
5252
echo "🚀 Starting to add topic '$TOPIC'..."
53-
53+
5454
while IFS= read -r repo; do
5555
echo "Working on $repo ... "
5656
# Check if topic already set
5757
CURRENT_TOPICS=$(gh repo view "$repo" --json repositoryTopics -q '.repositoryTopics[].name' 2>/dev/null || echo "")
5858
5959
if echo "$CURRENT_TOPICS" | grep -qw "$TOPIC"; then
60-
echo "уже имеет топик"
60+
echo "topic already set"
6161
continue
6262
fi
63-
# if gh repo edit "$repo" --add-topic "$TOPIC" >/dev/null 2>&1; then
64-
# echo "✅ topic added"
65-
# else
66-
# echo "❌ error"
67-
# fi
63+
if gh repo edit "$repo" --add-topic "$TOPIC" >/dev/null 2>&1; then
64+
echo "✅ topic added"
65+
else
66+
echo "❌ error"
67+
fi
6868
done < repos_without_file.txt
69-
69+
7070
echo "🎉 Done! Topic '$TOPIC' added to all target repositories."

config/examples/grand-report.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
3+
}

0 commit comments

Comments
 (0)