Skip to content

Commit 11d8104

Browse files
ivan-hcweb-flow
andauthored
Keep this site sync with AM (workflow) (#57)
* Add sync-with-AM.yml * Update sync-with-AM.yml * Sync files from source repository * Delete .github/workflows/lister.yml * Delete .github/workflows/icons-dumb.yml * Delete .github/workflows/cleaner.yml --------- Co-authored-by: Portable-Linux-Apps <[email protected]>
1 parent b9bf634 commit 11d8104

File tree

9 files changed

+112
-155
lines changed

9 files changed

+112
-155
lines changed

.github/workflows/cleaner.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/icons-dumb.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/lister.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/sync-with-AM.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: "Keep this site sync with AM"
2+
3+
on:
4+
schedule:
5+
- cron: "*/30 * * * *"
6+
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
sync-files:
18+
name: "Run sync"
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: "Checkout source repository"
22+
uses: actions/checkout@v4
23+
24+
- name: "Update lists"
25+
run: |
26+
AM2PLA_SCRIPT=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/tools/am2pla-site)
27+
[ -n "$AM2PLA_SCRIPT" ] && echo "$AM2PLA_SCRIPT" | grep -q "^AMREPO=" && echo "◆ Update am2pla-site script..." && echo "$AM2PLA_SCRIPT" > ./am2pla-site
28+
sed -i 's/^cd "$(xdg-user-dir DESKTOP)"/#cd "$(xdg-user-dir DESKTOP)"/g' ./am2pla-site
29+
[ ! -x ./am2pla-site ] && chmod a+x ./am2pla-site
30+
./am2pla-site
31+
32+
- name: "Remove unneeded pages/icons"
33+
run: |
34+
AMD64_LIST=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/programs/x86_64-apps)
35+
if [ -n "$AMD64_LIST" ] && echo "$AMD64_LIST" 2>/dev/null | grep -q "^◆ "; then
36+
37+
MDS=$(ls apps/* | sed 's:.*/::; s/.md$//g')
38+
PNGS=$(ls icons/* | sed 's:.*/::; s/.png$//g')
39+
for m in $MDS; do
40+
if ! echo "$AMD64_LIST" 2>/dev/null | grep -q "◆ $m :"; then
41+
rm -f "apps/$m.md"
42+
echo "Removed apps/$m.md"
43+
fi
44+
done
45+
46+
for p in $PNGS; do
47+
if ! echo "$AMD64_LIST" 2>/dev/null | grep -q "◆ $p :"; then
48+
rm -f "icons/$p.png"
49+
echo "Removed icons/$p.png"
50+
fi
51+
done
52+
53+
fi
54+
55+
- name: "Create dumb pages/icons if missing"
56+
run: |
57+
[ -z "$AMD64_LIST" ] && AMD64_LIST=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/programs/x86_64-apps)
58+
if [ -n "$AMD64_LIST" ] && echo "$AMD64_LIST" | grep -q "^◆ "; then
59+
60+
APPS=$(echo "$AMD64_LIST" | awk '{print $2}' | xargs)
61+
for a in $APPS; do
62+
if ! test -f apps/"$a".md; then
63+
INSTALLATION_SCRIPT=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/programs/x86_64/"$a")
64+
if [ -n "$INSTALLATION_SCRIPT" ] && echo "$INSTALLATION_SCRIPT" | grep -q "^APP=$a"; then
65+
APP=$(echo "$a" | tr '[:lower:]' '[:upper:]')
66+
DESCRIPTION=$(echo "$AMD64_LIST" | grep "^◆ $a :" | sed "s/^◆ $a ://g")
67+
68+
if echo "$INSTALLATION_SCRIPT" | grep -q "^SITE="; then
69+
site_ref=$(echo "$INSTALLATION_SCRIPT" | grep "^SITE=" | head -1 | awk -F'"' '$0=$2')
70+
if echo "$INSTALLATION_SCRIPT" | grep -q "^version=.*curl .*codeberg.org"; then
71+
SITE="https://codeberg.org/$site_ref"
72+
elif echo "$INSTALLATION_SCRIPT" | grep -q "^version=.*curl .*api.github.com" || ! echo "$site_ref" | grep -q "^http://\|https://\|ftp://"; then
73+
SITE="https://github.com/$site_ref"
74+
else
75+
SITE="$site_ref"
76+
fi
77+
else
78+
SITE="https://$(echo "$INSTALLATION_SCRIPT" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | head -1 | awk -F[/:] '{print $4}')"
79+
fi
80+
81+
echo "# $APP" > apps/"$a".md
82+
printf "\n$DESCRIPTION\n" >> apps/"$a".md
83+
printf "\n SITE/SOURCE: $SITE\n\n" >> apps/"$a".md
84+
printf " | [Applications](https://portable-linux-apps.github.io/apps.html) | [Home](https://portable-linux-apps.github.io)\n | --- | --- |" >> apps/"$a".md
85+
86+
echo "Adding apps/$a.md"
87+
fi
88+
fi
89+
done
90+
91+
MDS=$(ls apps/* | sed 's:.*/::; s/.md$//g')
92+
for m in $MDS; do
93+
if ! test -f icons/"$m".png; then
94+
cp -r no-icon.png "icons/$m.png"
95+
echo "Adding icons/$m.png"
96+
fi
97+
done
98+
rm -f icons/*.md
99+
100+
fi
101+
102+
- name: "Push to Source"
103+
run: |
104+
git config --global user.name "Portable-Linux-Apps"
105+
git config --global user.email "[email protected]"
106+
git add *.md *.json am2pla-site apps icons
107+
if git diff-index --quiet HEAD; then
108+
echo "No changes to commit." >> $GITHUB_STEP_SUMMARY
109+
else
110+
git commit -m "Sync files from source repository"
111+
git push && echo "Sync to Source succeeded" >> $GITHUB_STEP_SUMMARY
112+
fi

apps/owncloud.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

apps/swift.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

icons/memoto.png

4.17 KB
Loading

icons/owncloud.png

-6.96 KB
Binary file not shown.

icons/swift.png

-11 KB
Binary file not shown.

0 commit comments

Comments
 (0)