forked from ankurparihar/readme-pagespeed-insights
-
Notifications
You must be signed in to change notification settings - Fork 2
47 lines (47 loc) · 1.8 KB
/
pagespeed.yml
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
name: PSI-scores-to-SVG
on:
push:
branches:
- main
jobs:
getpsresults:
env:
URLS: YOUR_WEBSITE_URL
PSURL: https://pagespeed-insights-svg.glitch.me
PSRDESKTOP: psi-audit-desktop
PSRMOBILE: psi-audit-mobile
RESULTSFOLDER: reports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Create local changes
run: |
mkdir -p ${RESULTSFOLDER}
IFS=',' read -r -a HOSTS <<< $URLS
for i in "${!HOSTS[@]}"; do
position=$(( $i + 1 ))
while [ ! "$auditDesktop" ]; do
auditDesktop=$(curl "${PSURL}/?url=${HOSTS[$i]}&theme=dark&categories=30&tests=3")
done
cat <<< "$auditDesktop" > ./${RESULTSFOLDER}/${PSRDESKTOP}-${position}.svg
while [ ! "$auditMobile" ]; do
auditMobile=$(curl "${PSURL}/?url=${HOSTS[$i]}&strategy=mobile&theme=dark&categories=30&tests=3")
done
cat <<< "$auditMobile" > ./${RESULTSFOLDER}/${PSRMOBILE}-${position}.svg
unset auditDesktop
unset auditMobile
done
- name: Commit files
run: |
git add .
git config --local user.email "actions@github.com"
git config --local user.name "github-actions[bot]"
git diff --quiet && git diff --staged --quiet || git commit -am "🔁 CI" -m "Updated PageSpeed Insights results SVGs"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}