Skip to content

Keep this site sync with AM #9910

Keep this site sync with AM

Keep this site sync with AM #9910

Workflow file for this run

name: "Keep this site sync with AM"
on:
schedule:
- cron: "*/30 * * * *"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
sync-files:
name: "Run sync"
runs-on: ubuntu-latest
steps:
- name: "Checkout source repository"
uses: actions/checkout@v7
- name: "Remove unneeded pages/icons"
run: |
AMD64_LIST=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/programs/x86_64-apps)
if [ -n "$AMD64_LIST" ] && echo "$AMD64_LIST" 2>/dev/null | grep -q "^◆ "; then
rm -f apps/*.json apps/*.md
for f in apps/*; do
name=$(echo "$f" | sed 's:.*/::; s/\.\(md\|json\)$//')
if ! echo "$AMD64_LIST" 2>/dev/null | grep -q "◆ $name :"; then
rm -f "apps/$name"
echo "Removed apps/$name"
fi
done
fi
- name: "Create dumb pages/icons if missing"
run: |
[ -z "$AMD64_LIST" ] && AMD64_LIST=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/programs/x86_64-apps)
if [ -n "$AMD64_LIST" ] && echo "$AMD64_LIST" 2>/dev/null | grep -q "^◆ "; then
APPS=$(echo "$AMD64_LIST" 2>/dev/null | awk '{print $2}' | xargs)
for a in $APPS; do
if ! test -f apps/"$a"; then
INSTALLATION_SCRIPT=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/programs/x86_64/"$a")
if [ -n "$INSTALLATION_SCRIPT" ] && echo "$INSTALLATION_SCRIPT" 2>/dev/null | grep -Eq "^APP=[\"']?$a[\"']?\$"; then
DESCRIPTION=$(echo "$AMD64_LIST" 2>/dev/null | grep "^◆ $a :" | sed "s/^◆ $a ://g")
if echo "$INSTALLATION_SCRIPT" 2>/dev/null | grep -Eq "SITE[0-9]*="; then
SITE_REFS=$(echo "$INSTALLATION_SCRIPT" 2>/dev/null | grep -Eo "SITE[0-9]*=[\"'][^\"']*[\"']" | sed -E "s/^SITE[0-9]*=[\"']//; s/[\"']\$//" | awk '!seen[$0]++')
if [ -z "$SITE_REFS" ]; then
if echo "$INSTALLATION_SCRIPT" 2>/dev/null | grep -q "^version=.*curl .*api.github.com"; then
SITE=$(echo "$INSTALLATION_SCRIPT" 2>/dev/null | grep "^version" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | head -1 | sed 's#//api.#//#g; s#/repos/#/#g; s#/releases.*##')
else
SITE=$(echo "$INSTALLATION_SCRIPT" 2>/dev/null | grep "^version" | grep -Eo "(http|https)://[a-zA-Z0-9.?=_%:-]*" | head -1)
fi
else
SITE=""
while IFS= read -r site_ref; do
[ -z "$site_ref" ] && continue
case "$site_ref" in
http://*|https://*|ftp://*)
resolved="$site_ref"
;;
*)
resolved="https://github.com/$site_ref"
;;
esac
SITE="$SITE $resolved"
done <<< "$SITE_REFS"
SITE=$(echo "$SITE" | xargs)
fi
else
SITE="https://$(echo "$INSTALLATION_SCRIPT" 2>/dev/null | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | head -1 | awk -F[/:] '{print $4}')"
fi
ESC_DESC=$(echo "$DESCRIPTION" | sed 's/"/\\"/g')
printf '# %s\n===\n%s\n===\n# SCREENSHOTS: %s\n# SITES: %s\n' \
"$a" "$ESC_DESC" "/contribute_ss.webp /contribute_ss.webp" "$SITE" > apps/"$a"
echo "Adding apps/$a"
fi
fi
done
fi
- name: "Push to Source"
run: |
git config --global user.name "Portable-Linux-Apps"
git config --global user.email "noreply@github.com"
git add 'apps/' 'icons/*.png'
if ! git diff-index --cached --quiet HEAD; then
git commit -m "Sync files from source repository"
git push origin
else
echo "No changes to commit."
fi