1+ name : Eleventy Build and Deploy
2+
3+ on :
4+ push :
5+ branches :
6+ - main # Or master, or whichever branch your source code is on
7+
8+ jobs :
9+ build_and_deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout code
14+ uses : actions/checkout@v4
15+
16+ - name : Set up Node.js
17+ uses : actions/setup-node@v4
18+ with :
19+ node-version : ' 20' # Use the Node.js version you use locally (e.g., 20.x)
20+ cache : ' npm'
21+
22+ - name : Install dependencies
23+ run : npm ci # 'ci' is generally preferred for CI environments
24+
25+ - name : Build with Eleventy
26+ run : npm run build # This runs 'eleventy' which outputs to the 'docs' folder
27+
28+ - name : Deploy to GitHub Pages
29+ uses : peaceiris/actions-gh-pages@v4
30+ with :
31+ github_token : ${{ secrets.GITHUB_TOKEN }}
32+ publish_dir : ./docs # Directory that Eleventy builds to
33+ # For a User/Organization page (like <username>.github.io):
34+ # The 'gh-pages' branch is typically used for Project Pages.
35+ # For User Pages, you often push the build output back to the 'main' branch's '/docs' folder
36+ # OR to a dedicated 'gh-pages' branch that is then set as the source.
37+ #
38+ # If your repo is <username>.github.io and GitHub Pages is set to deploy from 'main' /docs:
39+ # You need an action that commits the 'docs' folder back to the 'main' branch.
40+ # The peaceiris/actions-gh-pages action often deploys to a separate 'gh-pages' branch by default.
41+ #
42+ # Let's adjust for pushing the 'docs' folder contents to the 'gh-pages' branch,
43+ # and then you'll set GitHub Pages to deploy from 'gh-pages' branch /root.
44+ # This keeps your 'main' branch for source code only.
45+ publish_branch : gh-pages # Deploy to the gh-pages branch
46+ # user_name: 'github-actions[bot]' # Optional
47+ # user_email: 'github-actions[bot]@users.noreply.github.com' # Optional
48+ # commit_message: 'Deploy Eleventy site to Pages' # Optional
0 commit comments