mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 14:13:52 +03:00
d07c5cf69c
code.forgejo.org is meant for development, the actions need to be highly available and can be read-only. This is what data.forgejo.org will provide.
39 lines
1.4 KiB
YAML
39 lines
1.4 KiB
YAML
on:
|
|
workflow_dispatch:
|
|
|
|
schedule:
|
|
- cron: '@daily'
|
|
|
|
jobs:
|
|
integration-cleanup:
|
|
if: vars.ROLE == 'forgejo-integration'
|
|
runs-on: docker
|
|
container:
|
|
image: 'data.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
|