@@ -13,45 +13,74 @@ permissions:
13
13
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
14
14
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
15
15
concurrency :
16
- group : " pages"
17
- cancel-in-progress : false
16
+ group : pages-${{ github.ref }}
17
+ cancel-in-progress : true
18
18
19
19
jobs :
20
- # Build job
20
+ # Build and optimize job
21
21
build :
22
22
runs-on : ubuntu-latest
23
23
steps :
24
24
- name : Checkout
25
25
uses : actions/checkout@v4
26
-
27
- - name : Setup Ruby
28
- uses : ruby /setup-ruby@v1
26
+
27
+ - name : Setup Node.js
28
+ uses : actions /setup-node@v4
29
29
with :
30
- ruby-version : ' 3.1'
31
- bundler-cache : true
30
+ node-version : ' 18'
31
+ cache : ' npm'
32
+
33
+ - name : Install build dependencies
34
+ run : |
35
+ npm init -y
36
+ npm install --save-dev html-minifier-terser clean-css-cli terser html-validate
37
+
38
+ - name : Validate HTML files
39
+ run : |
40
+ echo "Validating HTML files..."
41
+ npx html-validate *.html pages/*.html || echo "HTML validation completed with warnings"
42
+
43
+ - name : Optimize assets
44
+ run : |
45
+ echo "Optimizing HTML files..."
46
+ # Create backup directory
47
+ mkdir -p .backup
48
+
49
+ # Minify HTML files (preserve original structure)
50
+ find . -name "*.html" -not -path "./node_modules/*" -not -path "./.backup/*" | while read file; do
51
+ echo "Minifying: $file"
52
+ npx html-minifier-terser \
53
+ --collapse-whitespace \
54
+ --remove-comments \
55
+ --remove-optional-tags \
56
+ --remove-redundant-attributes \
57
+ --remove-script-type-attributes \
58
+ --remove-style-link-type-attributes \
59
+ --minify-css \
60
+ --minify-js \
61
+ "$file" -o "$file.tmp" && mv "$file.tmp" "$file"
62
+ done
32
63
64
+ # Minify CSS files if any exist
65
+ if find . -name "*.css" -not -path "./node_modules/*" -not -path "./.backup/*" | grep -q .; then
66
+ echo "Optimizing CSS files..."
67
+ find . -name "*.css" -not -path "./node_modules/*" -not -path "./.backup/*" | while read file; do
68
+ echo "Minifying: $file"
69
+ npx cleancss "$file" -o "$file"
70
+ done
71
+ fi
72
+
73
+ # Remove build dependencies from final artifact
74
+ rm -rf node_modules package*.json
75
+
33
76
- name : Setup Pages
34
77
id : pages
35
78
uses : actions/configure-pages@v4
36
-
37
- - name : Install dependencies
38
- run : |
39
- gem install jekyll bundler
40
- bundle init
41
- echo 'gem "jekyll", "~> 4.3"' >> Gemfile
42
- echo 'gem "minima", "~> 2.5"' >> Gemfile
43
- echo 'gem "jekyll-feed"' >> Gemfile
44
- echo 'gem "jekyll-sitemap"' >> Gemfile
45
- echo 'gem "jekyll-seo-tag"' >> Gemfile
46
- bundle install
47
-
48
- - name : Build with Jekyll
49
- run : bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
50
- env :
51
- JEKYLL_ENV : production
52
-
79
+
53
80
- name : Upload artifact
54
81
uses : actions/upload-pages-artifact@v3
82
+ with :
83
+ path : ' .'
55
84
56
85
# Deployment job
57
86
deploy :
60
89
url : ${{ steps.deployment.outputs.page_url }}
61
90
runs-on : ubuntu-latest
62
91
needs : build
63
- if : github.ref == 'refs/heads/main'
64
92
steps :
65
93
- name : Deploy to GitHub Pages
66
94
id : deployment
0 commit comments