From 17211925b3791b7bd4c82b9ffee821771f991b9f Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Thu, 2 Jan 2025 05:58:15 -0600 Subject: [PATCH] mirror laste 49 versions, prune the rest. --- .forgejo/workflows/mirror.yaml | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .forgejo/workflows/mirror.yaml diff --git a/.forgejo/workflows/mirror.yaml b/.forgejo/workflows/mirror.yaml new file mode 100644 index 0000000..221a0cc --- /dev/null +++ b/.forgejo/workflows/mirror.yaml @@ -0,0 +1,44 @@ +name: mirror + +on: + schedule: + - cron: '13 */6 * * *' # https://crontab.guru/#13_*/6_*_*_* + + workflow_dispatch: + + +jobs: + sync-renovate: + if: secrets.MIRROR_TOKEN != '' + runs-on: docker + container: + image: alpine:3.21@sha256:21dc6063fd678b478f57c0e13f47560d0ea4eeba26dfc947b2a4f81f686b9f45 + + steps: + - name: Install packages + run: | + apk add --no-cache \ + jq \ + git \ + nodejs \ + skopeo \ + ; + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + show-progress: false + + - name: Docker login + run: | + skopeo login --username jahanson --password '${{ secrets.MIRROR_TOKEN }}' git.hsn.dev + + - name: Copy renovate images + run: | + skopeo sync --all --preserve-digests --keep-going --src yaml --dest docker skopeo.yml git.hsn.dev/jahanson/renovate + + - name: Cleanup renovate images + run: | + skopeo list-tags docker://git.hsn.dev/jahanson/renovate/renovate | jq -r '.Tags[]' | sed -n -Ee '/^[0-9]+\.[0-9]+\.[0-9]+/p' | sort -r -V | sed -n '50,$p' | while read version ; \ + do echo "deleting $version" ; \ + skopeo delete docker://git.hsn.dev/jahanson/renovate/renovate:$version ; \ + done