Skip to content

Commit 027605d

Browse files
Update make-update-github-releases.yml
Signed-off-by: LUIZ HAMILTON ROBERTO DA SILVA <[email protected]>
1 parent 91e4291 commit 027605d

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

.github/workflows/make-update-github-releases.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ jobs:
3535
SysAdmin-Tools
3636
3737
steps:
38+
- name: 🧰 Install Dependencies (gh)
39+
shell: bash
40+
run: |
41+
set -euo pipefail
42+
sudo apt-get update
43+
sudo apt-get install -y gh
44+
3845
- name: 🔐 Verify GitHub CLI Auth
3946
shell: bash
4047
run: |
@@ -58,9 +65,9 @@ jobs:
5865
5966
deleted=0
6067
61-
# Stream tag_name for ALL releases (paginated; no fixed limit)
68+
# Get ALL releases (paginated) and extract tag_name
6269
mapfile -t release_tags < <(
63-
gh api --repo "$repo" --paginate "repos/${owner}/${name}/releases?per_page=100" --jq '.[].tag_name'
70+
gh api --paginate "repos/${owner}/${name}/releases?per_page=100" --jq '.[].tag_name'
6471
)
6572
6673
if [[ "${#release_tags[@]}" -eq 0 ]]; then
@@ -73,7 +80,8 @@ jobs:
7380
# Delete ANY release whose tag_name begins with "<prefix>-"
7481
if [[ "$tag" == "${prefix}-"* ]]; then
7582
echo "Deleting release: ${tag}"
76-
gh release delete "${tag}" --yes --repo "$repo" || true
83+
# IMPORTANT: release delete uses --repo to avoid "not a git repository"
84+
gh release delete "${tag}" --yes --repo "${repo}" || true
7785
deleted=$((deleted + 1))
7886
break
7987
fi
@@ -98,15 +106,16 @@ jobs:
98106
echo "Scanning tags for prefix: ${prefix}-"
99107
100108
mapfile -t refs < <(
101-
gh api --repo "$repo" --paginate "repos/${owner}/${name}/git/matching-refs/tags/${prefix}-" --jq '.[].ref'
109+
gh api --paginate "repos/${owner}/${name}/git/matching-refs/tags/${prefix}-" --jq '.[].ref'
102110
)
103111
104112
for ref in "${refs[@]}"; do
105113
# ref like: refs/tags/<tagname>
106114
tag="${ref#refs/tags/}"
107-
108115
echo "Deleting tag ref: ${ref}"
109-
gh api --repo "$repo" -X DELETE "repos/${owner}/${name}/git/refs/tags/${tag}" >/dev/null 2>&1 || true
116+
117+
# NOTE: gh api has NO --repo flag. Always use full endpoint.
118+
gh api -X DELETE "repos/${owner}/${name}/git/refs/tags/${tag}" >/dev/null 2>&1 || true
110119
deleted=$((deleted + 1))
111120
done
112121
done

0 commit comments

Comments
 (0)