-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (156 loc) · 6.25 KB
/
deploy.yml
File metadata and controls
177 lines (156 loc) · 6.25 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
172
173
174
175
176
177
name: deploy
# Deploy the site to GitHub Pages
on:
push:
branches: ["main"]
paths-ignore:
- '.github/**'
workflow_dispatch:
inputs:
confirm_manual_deploy:
description: 'Are you *sure* a manual deployment is absolutely necessary?'
required: true
type: boolean
default: false
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
thumbnails:
runs-on: ubuntu-latest
if: github.event_name != 'workflow_dispatch' || inputs.confirm_manual_deploy
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if we need to generate thumbnails
id: check_changes
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] || git diff --name-only HEAD^ HEAD | grep -q "assets/images/fulls/"; then
echo "Changes detected in assets/images/fulls/ or workflow dispatched manually, generating thumbnails"
echo "changes_detected=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "No changes detected in assets/images/fulls/, skipping thumbnail generation"
echo "changes_detected=false" >> $GITHUB_OUTPUT
- name: Install FUSE and ImageMagick 7
if: steps.check_changes.outputs.changes_detected == 'true'
run: |
sudo apt-get update
sudo apt-get install -y fuse
wget -q https://imagemagick.org/archive/binaries/magick
chmod +x magick
sudo mv magick /usr/local/bin/
magick -version
- name: Create thumbs directory if not exists
if: steps.check_changes.outputs.changes_detected == 'true'
run: mkdir -p assets/images/thumbs
- name: Generate thumbnails
if: steps.check_changes.outputs.changes_detected == 'true'
run: |
rm assets/images/thumbs/*.jpg
for img in assets/images/fulls/*.jpg; do
filename=$(basename "$img")
magick "$img" -resize "500x" "assets/images/thumbs/$filename"
done
- name: Generate Image List
id: generate-list
if: steps.check_changes.outputs.changes_detected == 'true'
run: |
rm archive/README.md
{
echo "[//]: # (This file is managed by the generate-list step in the deploy GitHub Action. Changes will be overwritten.)"
echo "# Image Archive Gallery"
echo ""
echo "Thank you for taking the time to view our gallery, exploring some of the photographic history of our band. We hope you enjoy the images of our band members and performances."
echo ""
for img in $(ls assets/images/fulls); do
thumb="https://efpb.org/assets/images/thumbs/$img"
full="https://efpb.org/assets/images/fulls/$img"
echo "[]($full)"
echo ""
echo ""
done
echo ""
echo "Return to the [Main Gallery](https://efpb.org)"
echo ""
} > archive/README.md
- name: Commit and push if changed
if: steps.check_changes.outputs.changes_detected == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add assets/images/thumbs/
git add archive/README.md
git diff --quiet && git diff --staged --quiet || (git commit -m "Generate thumbnails" && git push)
build:
needs: thumbnails
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check markdown files have corresponding images
run: |
# Check if each markdown file has a corresponding full-size image
for md_file in _images/*.md; do
base_name=$(basename "$md_file" .md)
if [ ! -f "assets/images/fulls/$base_name.jpg" ]; then
echo "Error: Missing image for $md_file"
echo "Expected: assets/images/fulls/$base_name.jpg"
echo "Please ensure that all _images/*.md files have corresponding images in assets/images/fulls/"
exit 1
fi
done
# Check if each markdown file has a corresponding thumbnail image
for md_file in _images/*.md; do
base_name=$(basename "$md_file" .md)
if [ ! -f "assets/images/thumbs/$base_name.jpg" ]; then
echo "Error: Missing thumbnail for $md_file"
echo "Expected: assets/images/thumbs/$base_name.jpg"
echo "Please ensure that all _images/*.md files have corresponding thumbnails in assets/images/thumbs/"
exit 1
fi
done
# Check if each image has a corresponding markdown file
for img_file in assets/images/fulls/*.jpg; do
base_name=$(basename "$img_file" .jpg)
if [ ! -f "_images/$base_name.md" ]; then
echo "⚠️ Warning: Missing markdown file for $img_file"
echo "Expected: _images/$base_name.md"
echo "If you want the image to be displayed, please ensure that it has a corresponding markdown file in _images/"
echo "This will not break the build, but the image will not be displayed on the main gallery"
fi
done
echo "✅ All _images markdown files have corresponding full and thumbnail images"
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
- name: Install Dependencies
run: |
gem install bundler
bundle install
- name: Build with Jekyll
run: bundle exec jekyll build
env:
JEKYLL_ENV: production
PAGES_REPO_NWO: ${{ github.repository }}
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4