summaryrefslogtreecommitdiffstats
path: root/.forgejo/workflows/forgejo-integration-cleanup.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
committerDaniel Baumann <daniel@debian.org>2024-12-12 23:57:56 +0100
commite68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch)
tree97775d6c13b0f416af55314eb6a89ef792474615 /.forgejo/workflows/forgejo-integration-cleanup.yml
parentInitial commit. (diff)
downloadforgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz
forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to '')
-rw-r--r--.forgejo/workflows/forgejo-integration-cleanup.yml39
1 files changed, 39 insertions, 0 deletions
diff --git a/.forgejo/workflows/forgejo-integration-cleanup.yml b/.forgejo/workflows/forgejo-integration-cleanup.yml
new file mode 100644
index 0000000..049679a
--- /dev/null
+++ b/.forgejo/workflows/forgejo-integration-cleanup.yml
@@ -0,0 +1,39 @@
+on:
+ workflow_dispatch:
+
+ schedule:
+ - cron: '@daily'
+
+jobs:
+ integration-cleanup:
+ if: vars.ROLE == 'forgejo-integration'
+ runs-on: docker
+ container:
+ image: 'code.forgejo.org/oci/node:20-bookworm'
+ steps:
+
+ - name: apt install curl jq
+ run: |
+ export DEBIAN_FRONTEND=noninteractive
+ apt-get update -qq
+ apt-get -q install -qq -y curl jq
+
+ - name: remove old releases and tags
+ run: |
+ url=https://any:${{ secrets.TOKEN }}@codeberg.org
+ curl -sS "$url/api/v1/repos/forgejo-integration/forgejo/releases" | jq -r '.[] | "\(.published_at) \(.tag_name)"' | sort | while read published_at version ; do
+ if echo $version | grep -e '-test$' >/dev/null; then
+ old="18 months"
+ else
+ old="1 day"
+ fi
+ too_old=$(env -i date --date="- $old" +%F)
+ too_old_seconds=$(env -i date --date="- $old" +%s)
+ published_at_seconds=$(env -i date --date="$published_at" +%s)
+ if test $published_at_seconds -le $too_old_seconds ; then
+ echo "$version was published more than $old ago ($published_at <= $too_old) and will be removed"
+ curl -X DELETE -sS "$url/api/v1/repos/forgejo-integration/forgejo/releases/tags/$version"
+ else
+ echo "$version was published less than $old ago"
+ fi
+ done