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

40 lines
1.6 KiB
YAML
Raw Normal View History

2024-10-16 02:37:57 +00:00
on:
workflow_dispatch:
2024-10-17 22:19:49 +00:00
schedule:
- cron: '@hourly'
2024-10-16 02:37:57 +00:00
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
2024-10-16 11:37:50 +00:00
downstream: https://ayakael.net/api/packages/alpine/alpine/edge/main
2024-10-16 02:37:57 +00:00
steps:
- name: Environment setup
2024-10-16 02:43:47 +00:00
run: apk add grep coreutils gawk curl
2024-10-16 02:37:57 +00:00
- 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
2024-10-16 02:37:57 +00:00
- name: Fetch info from downstream
run: |
2024-10-16 02:42:07 +00:00
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
2024-10-16 02:37:57 +00:00
- name: Missing apks detection
run: |
2024-10-16 02:42:59 +00:00
comm -23 upstream downstream | awk '{print $1}' > missing
2024-10-16 02:37:57 +00:00
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