Skip to content

Commit 9f230f0

Browse files
Copilotmadolson
andauthored
Add automatic PR validation workflow integrated with Zola deployment (#325)
This PR adds automatic build validation for pull requests to prevent website deployment failures by integrating PR validation directly into the existing Zola deployment workflow. ## Problem Currently, PRs are not validated to ensure the website will render correctly, which can result in deployment failures when changes are merged to the main branch. ## Solution Enhanced the existing `zola-deploy.yml` workflow to handle both PR validation and production deployment: - **Triggers on pull requests**: Added `pull_request` trigger targeting the main branch for validation - **Conditional deployment**: Uses `if: github.event_name != 'pull_request'` to skip deployment steps for PRs - **Smart checkout**: Automatically checks out PR branch for pull requests or main branch for deployments - **Unified build logic**: Both PR validation and deployment use identical build processes ## Benefits - **Prevents deployment failures**: Catches build issues before they reach production - **Immediate feedback**: Contributors get build validation results directly in their PRs - **Consistent validation**: Uses identical build logic as production deployment - **Reduced maintenance**: Single workflow file eliminates code duplication - **Minimal implementation**: Enhanced existing workflow instead of adding separate files The workflow validates: - TOML configuration syntax errors - Missing or broken content files - Template rendering problems - Sass compilation issues - Any other build-time errors This ensures that only PRs with valid, buildable changes can be merged, significantly reducing the risk of deployment failures while maintaining a clean, consolidated workflow structure. Fixes #324. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Madelyn Olson <[email protected]>
1 parent 7394309 commit 9f230f0

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

.github/workflows/zola-deploy.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Deploy website
33
on:
44
push:
55
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
68
repository_dispatch:
79
types: [deploy]
810
workflow_dispatch:
@@ -16,10 +18,12 @@ jobs:
1618
build:
1719
runs-on: ubuntu-latest
1820
steps:
19-
- name: Checkout prod
21+
- name: Checkout
2022
uses: actions/checkout@v4
2123
with:
22-
ref: main
24+
ref: >-
25+
${{ github.event_name == 'pull_request' &&
26+
github.head_ref || 'main' }}
2327
path: website
2428

2529
- name: Checkout valkey-doc
@@ -37,38 +41,45 @@ jobs:
3741
- name: Checkout valkey-bloom
3842
uses: actions/checkout@v4
3943
with:
40-
repository: valkey-io/valkey-bloom
41-
path: valkey-bloom
44+
repository: valkey-io/valkey-bloom
45+
path: valkey-bloom
4246

4347
- name: Checkout valkey-search
4448
uses: actions/checkout@v4
4549
with:
46-
repository: valkey-io/valkey-search
47-
path: valkey-search
50+
repository: valkey-io/valkey-search
51+
path: valkey-search
4852

4953
- name: Checkout valkey-json
5054
uses: actions/checkout@v4
5155
with:
52-
repository: valkey-io/valkey-json
53-
path: valkey-json
56+
repository: valkey-io/valkey-json
57+
path: valkey-json
5458

5559
- name: Init commands, topics and clients
5660
run: |
5761
cd website
58-
./build/init-topics-and-clients.sh ../valkey-doc/topics ../valkey-doc/clients
59-
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands ../valkey-json/src/commands ../valkey-search/src/commands
62+
./build/init-topics-and-clients.sh ../valkey-doc/topics \
63+
../valkey-doc/clients
64+
./build/init-commands.sh ../valkey-doc/commands \
65+
../valkey/src/commands ../valkey-bloom/src/commands \
66+
../valkey-json/src/commands ../valkey-search/src/commands
6067
6168
- name: Build only
6269
uses: shalzz/[email protected]
6370
env:
6471
BUILD_DIR: website
6572
BUILD_ONLY: true
6673
BUILD_THEMES: false
74+
6775
- name: Upload artifact
76+
if: github.event_name != 'pull_request'
6877
uses: actions/upload-pages-artifact@v3
6978
with:
7079
path: ./website/public
80+
7181
deploy:
82+
if: github.event_name != 'pull_request'
7283
environment:
7384
name: github-pages
7485
url: ${{ steps.deployment.outputs.page_url }}

0 commit comments

Comments
 (0)