mirrorer/.forgejo/workflows/sync-community.yml

38 lines
1.6 KiB
YAML
Raw Normal View History

2024-10-16 02:46:03 +00:00
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
2024-10-16 11:37:50 +00:00
downstream: https://ayakael.net/api/packages/alpine/alpine/edge/community
2024-10-16 02:46:03 +00:00
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"
2024-10-20 15:00:33 +00:00
# if fails continues to next
wget $upstream/x86_64/$pkgs.apk || continue
2024-10-16 02:46:03 +00:00
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file $pkgs.apk $downstream
rm $pkgs.apk
done < missing