mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 10:57:55 +01:00
find old PRs to delete
This commit is contained in:
parent
72a0e60f9f
commit
53d1f80e8a
1 changed files with 56 additions and 6 deletions
52
.github/workflows/clean_repo.yml
vendored
52
.github/workflows/clean_repo.yml
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
|
name: Clean Container Registry
|
||||||
on:
|
on:
|
||||||
#schedule:
|
#schedule:
|
||||||
# - cron: '39 21 * * *'
|
# - cron: '39 21 * * *'
|
||||||
|
|
@ -5,7 +6,7 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-container:
|
delete_untagged:
|
||||||
name: Delete untagged packages
|
name: Delete untagged packages
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -17,3 +18,52 @@ jobs:
|
||||||
repository: ${{ github.repository }}
|
repository: ${{ github.repository }}
|
||||||
untagged_only: true
|
untagged_only: true
|
||||||
owner_type: user
|
owner_type: user
|
||||||
|
delete_old_pr:
|
||||||
|
name: Delete untagged packages
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: read
|
||||||
|
steps:
|
||||||
|
- name: Get list of packages
|
||||||
|
id: all_tags
|
||||||
|
run: |
|
||||||
|
all_tags=$(curl -L \
|
||||||
|
-H "Accept: application/vnd.github+json" \
|
||||||
|
-H "Authorization: Bearer ${{ github.token }}" \
|
||||||
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
|
"https://api.github.com/user/packages/container/build-container-installer/versions" | \
|
||||||
|
jq -r '.[] | .metadata.container.tags | .[]' | \
|
||||||
|
tr '\n' ' ')
|
||||||
|
echo "tag_list=${all_tags}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Find Open PRs
|
||||||
|
id: open_prs
|
||||||
|
run: |
|
||||||
|
open_prs=$(curl -L \
|
||||||
|
-H "Accept: application/vnd.github+json" \
|
||||||
|
-H "Authorization: Bearer ${{ github.token }}" \
|
||||||
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
|
https://api.github.com/repos/${{ github.repository }}/pulls | \
|
||||||
|
jq -r '.[] | select(.state == "open") | .number' | \
|
||||||
|
sed 's/^/pr-/g' | \
|
||||||
|
tr '\n' ' ')
|
||||||
|
echo "open_prs=${open_prs}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Delete old PR packages
|
||||||
|
run: |
|
||||||
|
echo "${{ steps.open_prs.outputs.open_prs }}" | tr ' ' '\n' > open_prs
|
||||||
|
for tag in ${{ steps.all_tags.outputs.tag_list }}
|
||||||
|
do
|
||||||
|
if (grep -w ${tag} open_prs > /dev/null)
|
||||||
|
then
|
||||||
|
echo "PR is still open"
|
||||||
|
else
|
||||||
|
echo "${tag}" >> delete_tags
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Tags to delete:"
|
||||||
|
cat delete_tags
|
||||||
|
|
||||||
|
|
||||||
|
#delete_old_branches:
|
||||||
Loading…
Add table
Add a link
Reference in a new issue