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

39 lines
1.6 KiB
YAML

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/alpine/edge/main
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