Add community sync

This commit is contained in:
Antoine Martin 2024-10-15 22:46:03 -04:00
parent c5a4eb3128
commit 418ef820ce
Signed by: forge
GPG key ID: D62A472A4AA7D541

View file

@ -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