-
Notifications
You must be signed in to change notification settings - Fork 7
100 lines (81 loc) · 2.65 KB
/
build-and-deploy.yaml
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
name: Build and Deploy Quarto Site
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
jobs:
reduce-images:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Check for large image files
id: large-img-check
run: |
img_path=$(du -ah --threshold=1M | awk '/.(JPE?G|jpe?g|PNG|png|HEIC|heic)$/ {print $2}')
echo "$img_path"
if [[ -n "$img_path" ]]; then
echo "big_image=true" >> $GITHUB_OUTPUT
echo "img_path=$(echo $img_path)" >> $GITHUB_OUTPUT
fi
- name: Install ImageMagick
if: steps.large-img-check.outputs.big_image == 'true'
run: |
cd ..
wget https://imagemagick.org/archive/binaries/magick -o magick
chmod +x magick
- name: Shrink images
if: steps.large-img-check.outputs.big_image == 'true'
env:
img_path: ${{ steps.large-img-check.outputs.img_path }}
run: |
for image in $img_path; do
mogrify -resize 800 -quality 75 "$image"
done
# Body width in Quarto documents is 800 px by default
# https://quarto.org/docs/output-formats/page-layout.html#html-page-layout
# ImageMagick mogrify docs: https://imagemagick.org/script/mogrify.php
- name: Push changes
if: steps.large-img-check.outputs.big_image == 'true'
run: |
git config user.name github-actions
git config user.email [email protected]
git add --all
git commit --allow-empty -m "[auto] Reduce image file size"
git push origin HEAD:main
build-deploy:
needs: reduce-images
runs-on: ubuntu-latest
container: eco4cast/rocker-neon4cast:latest
steps:
- run: git config --global --add safe.directory /__w/efi-ci-workshop-2024/efi-ci-workshop-2024
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
set-safe-directory: '*'
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: 1.4.146
- name: Render
run: |
quarto render
- name: Publish
run: |
git config user.name github-actions
git config user.email [email protected]
git checkout gh-pages
cp -r docs/* .
git add .
git commit -a -m "update pages" || echo "nothing to commit"
git push https://${GITHUB_PAT}:${GITHUB_PAT}@github.com/${GITHUB_REPOSITORY}