-
Notifications
You must be signed in to change notification settings - Fork 56
93 lines (77 loc) · 2.44 KB
/
deploy.yml
File metadata and controls
93 lines (77 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: CI/CD Pipeline
on:
push:
branches: [ master, publish ]
pull_request:
branches: [ master, publish ]
permissions:
contents: write
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.5'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Lint JavaScript
run: npm run lint
- name: Build site
run: npm run build
env:
JEKYLL_ENV: production
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: site-build
path: _site/
retention-days: 1
# Deployment job - push built files to master branch
deploy:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/publish' && github.event_name == 'push'
steps:
- name: Checkout master branch
uses: actions/checkout@v5
with:
ref: master
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: site-build
path: _site/
- name: Deploy to master branch
run: |
# Configure git
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Remove all files except .git and _site
find . -maxdepth 1 ! -name '.git' ! -name '_site' ! -name '.' ! -name '..' -exec rm -rf {} +
# Copy built site files to root (GitHub Pages expects files in root, not in _site)
cp -r _site/* .
# Remove the _site directory (not needed for GitHub Pages)
rm -rf _site
# Add and commit changes
git add -A
if git diff --staged --quiet; then
echo "No changes to deploy"
else
git commit -m "CI deploy to gh-pages from publish@${{ github.sha }}"
git push origin master
fi