From 418ef820cef5e7e8d8b1a3350dea40960196ae13 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Tue, 15 Oct 2024 22:46:03 -0400 Subject: [PATCH] Add community sync --- .forgejo/workflows/sync-community.yml | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .forgejo/workflows/sync-community.yml diff --git a/.forgejo/workflows/sync-community.yml b/.forgejo/workflows/sync-community.yml new file mode 100644 index 0000000..4af2221 --- /dev/null +++ b/.forgejo/workflows/sync-community.yml @@ -0,0 +1,36 @@ +on: + workflow_dispatch: + +jobs: + mirror-community: + name: Mirror community apks downstream + runs-on: x86_64 + container: + image: alpine:latest + env: + upstream: https://dl-cdn.alpinelinux.org/alpine/edge/community + downstream: https://ayakael.net/api/packages/alpine-archive/alpine/edge/community + 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