From bc13e1a7d9bd7f9d3d8fa7de8e9d82feb2f8901c Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Tue, 15 Oct 2024 22:46:45 -0400 Subject: [PATCH] Add testing sync --- .forgejo/workflows/sync-testing.yml | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .forgejo/workflows/sync-testing.yml diff --git a/.forgejo/workflows/sync-testing.yml b/.forgejo/workflows/sync-testing.yml new file mode 100644 index 0000000..b903167 --- /dev/null +++ b/.forgejo/workflows/sync-testing.yml @@ -0,0 +1,36 @@ +on: + workflow_dispatch: + +jobs: + mirror-testing: + name: Mirror testing apks downstream + runs-on: x86_64 + container: + image: alpine:latest + env: + upstream: https://dl-cdn.alpinelinux.org/alpine/edge/testing + downstream: https://ayakael.net/api/packages/alpine-archive/alpine/edge/testing + steps: + - name: Environment setup + run: apk add grep coreutils gawk curl + - name: Fetch info from upstream + run: | + apk --allow-untrusted --update-cache --repositories-file /dev/null --repository $upstream update + apk --allow-untrusted --update-cache --repositories-file /dev/null --repository $upstream list | grep -v installed | awk '{print $1, $2}' | sort > upstream + - name: Fetch info from downstream + run: | + apk --allow-untrusted --update-cache --repositories-file /dev/null --repository $downstream update || true + apk --allow-untrusted --update-cache --repositories-file /dev/null --repository $downstream list | grep -v installed | awk '{print $1, $2}' | sort > downstream + - name: Missing apks detection + run: | + comm -23 upstream downstream | awk '{print $1}' > missing + echo "Missing apks:" + cat missing + - name: Send missing packages downstream + run: | + while read pkgs; do + echo "Sending $pkgs" + wget $upstream/x86_64/$pkgs.apk + curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file $pkgs.apk $downstream + rm $pkgs.apk + done < missing