1- # This workflow uses actions that are not certified by GitHub.
2- # They are provided by a third-party and are governed by
3- # separate terms of service, privacy policy, and support
4- # documentation.
1+ # Combined workflow for testing and deploying Jekyll site to GitHub Pages
2+ # Tests must pass before deployment proceeds
53
6- # Sample workflow for building and deploying a Jekyll site to GitHub Pages
7- name : Deploy Jekyll site to Pages
4+ name : Test and Deploy Jekyll site to Pages
85
96on :
107 # Runs on pushes targeting the default branch
118 push :
129 branches : ["master"]
10+ pull_request :
11+ branches : ["master"]
1312
1413 # Allows you to run this workflow manually from the Actions tab
1514 workflow_dispatch :
15+ inputs :
16+ update_snapshots :
17+ description : ' Update Playwright snapshots'
18+ required : false
19+ default : false
20+ type : boolean
1621
1722# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1823permissions :
@@ -27,32 +32,95 @@ concurrency:
2732 cancel-in-progress : false
2833
2934jobs :
30- # Build job
35+ # Test job - runs Playwright tests
36+ test :
37+ timeout-minutes : 60
38+ runs-on : ubuntu-latest
39+ steps :
40+ - name : Checkout
41+ uses : actions/checkout@v4
42+
43+ - name : Setup Ruby
44+ uses : ruby/setup-ruby@v1
45+ with :
46+ ruby-version : ' 3.1'
47+ bundler-cache : true
48+
49+ - name : Setup Node.js
50+ uses : actions/setup-node@v4
51+ with :
52+ node-version : ' 20'
53+ cache : ' npm'
54+
55+ - name : Install Node dependencies
56+ run : npm ci
57+
58+ - name : Install Playwright Browsers
59+ run : npx playwright install --with-deps chromium
60+
61+ - name : Run Playwright tests
62+ if : ${{ !inputs.update_snapshots }}
63+ run : npx playwright test
64+ env :
65+ BASE_URL : http://127.0.0.1:4000
66+
67+ - name : Update Playwright Snapshots
68+ if : ${{ inputs.update_snapshots }}
69+ run : npx playwright test --update-snapshots
70+ env :
71+ BASE_URL : http://127.0.0.1:4000
72+
73+ - name : Upload Playwright Report
74+ uses : actions/upload-artifact@v4
75+ if : ${{ !cancelled() }}
76+ with :
77+ name : playwright-report
78+ path : playwright-report/
79+ retention-days : 30
80+
81+ - name : Upload Test Results
82+ uses : actions/upload-artifact@v4
83+ if : ${{ !cancelled() }}
84+ with :
85+ name : test-results
86+ path : test-results/
87+ retention-days : 30
88+
89+ - name : Upload Updated Snapshots
90+ uses : actions/upload-artifact@v4
91+ if : ${{ inputs.update_snapshots }}
92+ with :
93+ name : updated-snapshots
94+ path : |
95+ tests/**/*.png
96+ tests/**/*.txt
97+ retention-days : 30
98+
99+ # Build job - only runs after tests pass
31100 build :
32101 runs-on : ubuntu-latest
102+ needs : test
103+ # Only build on push to master (not on PRs)
104+ if : github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.update_snapshots)
33105 steps :
34106 - name : Checkout
35107 uses : actions/checkout@v4
36108 - name : Setup Ruby
37- # https://github.com/ruby/setup-ruby/releases/tag/v1.207.0
38- uses : ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4
109+ uses : ruby/setup-ruby@v1
39110 with :
40- ruby-version : ' 3.1' # 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
111+ ruby-version : ' 3.1'
112+ bundler-cache : true
43113 - name : Setup Pages
44114 id : pages
45115 uses : actions/configure-pages@v5
46116 - name : Build with Jekyll
47- # Outputs to the './_site' directory by default
48117 run : bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
49118 env :
50119 JEKYLL_ENV : production
51120 - name : Upload artifact
52- # Automatically uploads an artifact from the './_site' directory by default
53121 uses : actions/upload-pages-artifact@v3
54122
55- # Deployment job
123+ # Deployment job - only runs after build succeeds
56124 deploy :
57125 environment :
58126 name : github-pages
0 commit comments