From 1239573b1740a551a59e049e5879d3688025ecc4 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Tue, 15 Oct 2024 22:37:57 -0400 Subject: [PATCH] Add sync main workflow --- .forgejo/workflows/sync-main.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .forgejo/workflows/sync-main.yml diff --git a/.forgejo/workflows/sync-main.yml b/.forgejo/workflows/sync-main.yml new file mode 100644 index 0000000..b9048ab --- /dev/null +++ b/.forgejo/workflows/sync-main.yml @@ -0,0 +1,39 @@ +on: + workflow_dispatch: + + schedule: + - cron: '@hourly' + +jobs: + mirror-main: + name: Mirror main apks downstream + runs-on: x86_64 + container: + image: alpine:latest + env: + upstream: https://dl-cdn.alpinelinux.org/alpine/edge/main + downstream: https://ayakael.net/api/packages/alpine-archive/alpine/edge/main + steps: + - name: Environment setup + run: apk add grep coreutils gawk + - 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 + 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 a b | 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