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/alpine/edge/community steps: - name: Environment setup run: apk add grep coreutils gawk curl wget - 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: | wc -l missing | awk '{print $1}' > total read total < total count=1 while read pkgs; do echo "[ $count / $total ] Sending $pkgs" # if fails continues to next if `wget -q $upstream/x86_64/$pkgs.apk`; then result=`curl -s --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file $pkgs.apk $downstream` if [ -n "$results" ]; then echo $result fi rm -f $pkgs.apk else echo "Error: Couldn't download $pkgs" fi count=$(( count + 1 )) done < missing