Repository navigation
171 lines (144 loc) · 5.46 KB
/
Copy pathdeploy-site.yml
File metadata and controls
171 lines (144 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Simple workflow for deploying static content to GitHub Pages
name: Deploy site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: main
workflow_run:
workflows: ["Keep this site sync with AM"]
types:
- completed
branches: main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build-and-deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
container:
image: registry.gitlab.com/kazam0180/pla-site-tool:latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Cache converted icons
id: icon-cache
uses: actions/cache@v6
with:
path: .cache/icons
key: icons-${{ hashFiles('icons/**', 'no-icon.png') }}
- name: Cache screenshots
id: screenshots-cache
uses: actions/cache@v6
with:
path: .cache/screenshots
key: screenshots-v1
- name: Build site
shell: bash
run: |
set -e
pla-site-tool gen-site > pla-site-tool.log 2>&1 &
PLA_PID=$!
imgtool -p . -o ./public convert-screenshots > screenshots.log 2>&1 &
SS_PID=$!
wait "$PLA_PID"; PLA_STATUS=$?
wait "$SS_PID"; SS_STATUS=$?
cat pla-site-tool.log screenshots.log | tee -a build-log.txt
[ $PLA_STATUS -eq 0 ] || { echo "pla-site-tool failed" | tee -a build-log.txt; exit 1; }
[ $SS_STATUS -eq 0 ] || { echo "imgtool convert-screenshots failed" | tee -a build-log.txt; exit 1; }
[ ! -x ./minify ] && chmod a+x ./minify
./minify public 2>&1 | tee -a build-log.txt
cp -t public/ favicon.ico *.webp *.jpg
cp -r assets/fonts public/assets/
cp -r casts public/
cp -r am-gui public/
cp -t public/ google*.html BingSiteAuth.xml
echo -n "${{ secrets.INDEXNOW_KEY }}" > "public/${{ secrets.INDEXNOW_KEY }}.txt"
echo "site generated" | tee -a build-log.txt
- name: Process icons
run: |
set -e
if [ -d .cache/icons ]; then
mkdir -p public/icons public/icons_48
cp -r .cache/icons/public/icons/. public/icons/
cp -r .cache/icons/public/icons_48/. public/icons_48/
cp .cache/icons/public/no-icon.webp public/no-icon.webp
cp .cache/icons/public/no-icon_48.webp public/no-icon_48.webp
echo "icons restored from cache" | tee -a build-log.txt
else
imgtool -p . -o ./public convert-icons 2>&1 | tee -a build-log.txt
mkdir -p .cache/icons/public
cp -r public/icons .cache/icons/public/
cp -r public/icons_48 .cache/icons/public/
cp public/no-icon.webp .cache/icons/public/
cp public/no-icon_48.webp .cache/icons/public/
fi
- name: Setup Pages
uses: actions/configure-pages@v6
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: 'public'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- name: Restore previous sitemap
uses: actions/cache/restore@v6
with:
path: .cache/sitemap-prev.xml
key: sitemap-prev-${{ github.run_id }}
restore-keys: |
sitemap-prev-
- name: Notify IndexNow
run: |
set -e
KEY=${{ secrets.INDEXNOW_KEY }}
grep -oP '(?<=<loc>)[^<]+' public/sitemap.xml | sort > /tmp/new.txt
if [ -f .cache/sitemap-prev.xml ]; then
grep -oP '(?<=<loc>)[^<]+' .cache/sitemap-prev.xml | sort > /tmp/old.txt
else
touch /tmp/old.txt
fi
comm -13 /tmp/old.txt /tmp/new.txt > /tmp/changed.txt
if [ -s /tmp/changed.txt ]; then
count=0
while IFS= read -r url; do
[ -z "$url" ] && continue
curl -sS -G "https://api.indexnow.org/indexnow" \
--data-urlencode "url=$url" \
--data-urlencode "key=$KEY" \
--data-urlencode "keyLocation=https://portable-linux-apps.github.io/$KEY.txt" \
-o /dev/null -w "%{http_code} $url\n" \
| tee -a build-log.txt
count=$((count + 1))
sleep 0.2
done < /tmp/changed.txt
echo "Submitted $count URL(s) to IndexNow individually" | tee -a build-log.txt
else
echo "No new/changed URLs to submit to IndexNow" | tee -a build-log.txt
fi
mkdir -p .cache
cp public/sitemap.xml .cache/sitemap-prev.xml
- name: Save current sitemap for next run
if: always()
uses: actions/cache/save@v6
with:
path: .cache/sitemap-prev.xml
key: sitemap-prev-${{ github.run_id }}
- name: Upload Build Log
if: always()
uses: actions/upload-artifact@v7
with:
name: build-log
path: build-log.txt