33# separate terms of service, privacy policy, and support
44# documentation.
55
6- # Sample workflow for building and deploying a Jekyll site to GitHub Pages
7- name : Deploy Jekyll site to Pages
6+ # Combined workflow for testing and deploying a Jekyll site to GitHub Pages
7+ name : CI/CD for Jekyll site
88
99on :
1010 # Runs on pushes targeting the default branch
1111 push :
1212 branches : ["main"]
1313
14+ # Runs on pull requests targeting the default branch
15+ pull_request :
16+ branches : ["main"]
17+
1418 # Allows you to run this workflow manually from the Actions tab
1519 workflow_dispatch :
1620
@@ -27,33 +31,66 @@ concurrency:
2731 cancel-in-progress : false
2832
2933jobs :
34+ # Test job
35+ test :
36+ if : github.event_name == 'pull_request'
37+ runs-on : ubuntu-latest
38+ steps :
39+ - name : Checkout
40+ uses : actions/checkout@v4
41+ - name : Setup Ruby
42+ uses : ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4
43+ with :
44+ ruby-version : ' 3.3'
45+ bundler-cache : true
46+ cache-version : 0
47+ - name : Install dependencies
48+ run : bundle install
49+ - name : Check for syntax errors
50+ run : bundle exec jekyll doctor
51+ - name : Build Jekyll site
52+ run : bundle exec jekyll build --strict_front_matter
53+ env :
54+ JEKYLL_ENV : development
55+ - name : Test HTML
56+ run : |
57+ gem install html-proofer
58+ htmlproofer ./_site --disable-external --check-html --check-img-http --check-opengraph
59+ - name : Test CSS
60+ run : |
61+ npm install -g csslint
62+ find ./_site -name "*.css" -exec csslint {} \;
63+ - name : Check links
64+ run : |
65+ gem install html-proofer
66+ htmlproofer ./_site --external_only --check-external-hash
67+
3068 # Build job
3169 build :
70+ if : github.event_name == 'push'
3271 runs-on : ubuntu-latest
3372 steps :
3473 - name : Checkout
3574 uses : actions/checkout@v4
3675 - name : Setup Ruby
37- # https://github.com/ruby/setup-ruby/releases/tag/v1.207.0
3876 uses : ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4
3977 with :
40- ruby-version : ' 3.3' # Not needed with a .ruby-version file
41- bundler-cache : true # runs 'bundle install' and caches installed gems automatically
42- cache-version : 0 # Increment this number if you need to re-download cached gems
78+ ruby-version : ' 3.3'
79+ bundler-cache : true
80+ cache-version : 0
4381 - name : Setup Pages
4482 id : pages
4583 uses : actions/configure-pages@v5
4684 - name : Build with Jekyll
47- # Outputs to the './_site' directory by default
4885 run : bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
4986 env :
5087 JEKYLL_ENV : production
5188 - name : Upload artifact
52- # Automatically uploads an artifact from the './_site' directory by default
5389 uses : actions/upload-pages-artifact@v4
5490
5591 # Deployment job
5692 deploy :
93+ if : github.event_name == 'push'
5794 environment :
5895 name : github-pages
5996 url : ${{ steps.deployment.outputs.page_url }}
0 commit comments