1- name : Build and deploy Jekyll site to GitHub Pages
1+ name : Build and Deploy Cypherpunks Taiwan V2.0
22
33on :
44 push :
55 branches :
66 - master
7+ pull_request :
8+ branches :
9+ - master
10+
11+ # Sets permissions of the GITHUB_TOKEN
12+ permissions :
13+ contents : write
14+ pages : write
15+ id-token : write
16+
17+ # Allow only one concurrent deployment
18+ concurrency :
19+ group : " pages"
20+ cancel-in-progress : true
721
822jobs :
9- build-and-deploy :
10- runs-on : ubuntu-22.04
11- permissions :
12- contents : write
23+ build :
24+ runs-on : ubuntu-latest
1325 steps :
14- - uses : actions/checkout@v4
15- - name : Set up Ruby
26+ - name : Checkout repository
27+ uses : actions/checkout@v4
28+
29+ # Setup Node.js for Tailwind CSS
30+ - name : Setup Node.js
31+ uses : actions/setup-node@v4
32+ with :
33+ node-version : ' 20'
34+ cache : ' npm'
35+
36+ - name : Install Node dependencies
37+ run : npm ci || npm install
38+
39+ - name : Build Tailwind CSS
40+ run : npm run css:build
41+
42+ # Setup Ruby for Jekyll
43+ - name : Setup Ruby
1644 uses : ruby/setup-ruby@v1
1745 with :
18- ruby-version : ' 3.0 '
46+ ruby-version : ' 3.2 '
1947 bundler-cache : true
20- - name : Install dependencies
48+
49+ - name : Install Ruby dependencies
2150 run : |
22- bundle config unset deployment
23- sudo gem install bundler:2.2.15
24- bundle install
25- bundle add kramdown-parser-gfm
26- bundle install
27- - name : Build site
28- run : bundle exec jekyll build
51+ bundle config set --local path 'vendor/bundle'
52+ bundle install --jobs 4 --retry 3
53+
54+ - name : Build Jekyll site
55+ run : |
56+ # Check if this is a project page (repo name != owner.github.io)
57+ REPO_NAME="${GITHUB_REPOSITORY#*/}"
58+ OWNER="${GITHUB_REPOSITORY_OWNER}"
59+ if [[ "$REPO_NAME" != "${OWNER}.github.io" ]]; then
60+ echo "Building for project page: baseurl=/${REPO_NAME}"
61+ bundle exec jekyll build --baseurl "/${REPO_NAME}"
62+ else
63+ echo "Building for user/org page: no baseurl"
64+ bundle exec jekyll build
65+ fi
66+ env :
67+ JEKYLL_ENV : production
68+
69+ - name : Build Pagefind search index
70+ run : npx pagefind --site _site --output-path _site/pagefind
71+
72+ - name : Upload artifact
73+ uses : actions/upload-pages-artifact@v3
74+ with :
75+ path : ./_site
76+
77+ deploy :
78+ if : github.ref == 'refs/heads/master'
79+ needs : build
80+ runs-on : ubuntu-latest
81+ environment :
82+ name : github-pages
83+ url : ${{ steps.deployment.outputs.page_url }}
84+ steps :
2985 - name : Deploy to GitHub Pages
30- uses : peaceiris/actions-gh-pages@v3
86+ id : deployment
87+ uses : actions/deploy-pages@v4
88+
89+ # Quality Checks (run on PRs)
90+ quality-check :
91+ if : github.event_name == 'pull_request'
92+ needs : build
93+ runs-on : ubuntu-latest
94+ steps :
95+ - name : Checkout
96+ uses : actions/checkout@v4
97+
98+ - name : Download artifact
99+ uses : actions/download-artifact@v4
100+ with :
101+ name : github-pages
102+ path : _site
103+
104+ - name : Extract artifact
105+ run : |
106+ cd _site
107+ tar -xvf artifact.tar
108+ rm artifact.tar
109+
110+ # Link Checker
111+ - name : Check links
112+ uses : lycheeverse/lychee-action@v1
31113 with :
32- github_token : ${{ secrets.GITHUB_TOKEN }}
33- publish_dir : ./_site
114+ args : --verbose --no-progress --accept 999 './_site/**/*.html'
115+ fail : false
116+
117+ # HTML Validation
118+ - name : Setup Node.js for html-validate
119+ uses : actions/setup-node@v4
120+ with :
121+ node-version : ' 20'
122+
123+ - name : Install html-validate
124+ run : npm install -g html-validate
125+
126+ - name : Validate HTML
127+ run : |
128+ html-validate --config .htmlvalidate.json "_site/**/*.html" || true
129+ continue-on-error : true
130+
131+ # Accessibility Check
132+ - name : Install pa11y
133+ run : npm install -g pa11y-ci
134+
135+ - name : Run accessibility check
136+ run : |
137+ pa11y-ci --config .pa11yci.json || true
138+ continue-on-error : true
139+
140+ # Image Compression (run on PRs with image changes)
141+ compress-images :
142+ if : github.event_name == 'pull_request'
143+ runs-on : ubuntu-latest
144+ steps :
145+ - name : Checkout
146+ uses : actions/checkout@v4
147+
148+ - name : Compress Images
149+ id : compress
150+ uses : calibreapp/image-actions@main
151+ with :
152+ githubToken : ${{ secrets.GITHUB_TOKEN }}
153+ compressOnly : true
154+ ignorePaths : ' node_modules/**,vendor/**,_site/**'
155+ continue-on-error : true
156+
157+ - name : Create image compression summary
158+ if : steps.compress.outputs.markdown != ''
159+ run : |
160+ echo "## Image Compression Results" >> $GITHUB_STEP_SUMMARY
161+ echo "${{ steps.compress.outputs.markdown }}" >> $GITHUB_STEP_SUMMARY
0 commit comments