-
Notifications
You must be signed in to change notification settings - Fork 3
113 lines (100 loc) · 3.32 KB
/
jekyll-gh-pages.yml
File metadata and controls
113 lines (100 loc) · 3.32 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: "Deploy Jekyll with GitHub Pages (robust: Gemfile auto-detect)"
on:
push:
branches:
- main
- master
workflow_dispatch: {}
schedule:
- cron: '0 12 * * *'
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages-${{ github.ref }}"
cancel-in-progress: false
jobs:
build:
name: Build site (Jekyll)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Detect Gemfile location
id: gemfile
run: |
# Prefer site/Gemfile if it exists
if [ -f "site/Gemfile" ]; then
echo "gemfile_dir=site" >> $GITHUB_OUTPUT
echo "Found Gemfile in site/ directory."
elif [ -f "Gemfile" ]; then
echo "gemfile_dir=." >> $GITHUB_OUTPUT
echo "Found Gemfile in repo root."
else
echo "No Gemfile found in repo root or site/ — failing early."
ls -la
exit 2
fi
- name: Setup Ruby (for Jekyll)
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: false # we use explicit cache step below
- name: Cache bundler gems (auto target)
uses: actions/cache@v4
id: cache-bundler
with:
path: vendor/bundle
# If Gemfile.lock is under site/, use that; else root path is used.
key: ${{ runner.os }}-gems-${{ steps.gemfile.outputs.gemfile_dir }}-${{ hashFiles(format('{0}/Gemfile.lock', steps.gemfile.outputs.gemfile_dir)) }}
restore-keys: |
${{ runner.os }}-gems-${{ steps.gemfile.outputs.gemfile_dir }}-
- name: Install Ruby gems (bundle install)
run: |
echo "Using Gemfile from: ${{ steps.gemfile.outputs.gemfile_dir }}"
cd ${{ steps.gemfile.outputs.gemfile_dir }}
bundle config set --local path 'vendor/bundle'
bundle install --jobs 4 --retry 3
shell: bash
- name: Build Jekyll site
run: |
echo "Building Jekyll from site/ to _site/"
# If your Jekyll source is in 'site', build from there; otherwise build from repository root.
if [ "${{ steps.gemfile.outputs.gemfile_dir }}" = "site" ]; then
cd site
bundle exec jekyll build --source . --destination ../_site
else
bundle exec jekyll build --source site --destination _site || bundle exec jekyll build --destination _site
fi
env:
JEKYLL_ENV: production
shell: bash
- name: Validate build
run: |
if [ ! -d "_site" ]; then
echo "_site wasn't generated — failing the job."
exit 1
fi
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./_site
name: java-evolution-pages
deploy:
name: Deploy to GitHub Pages
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
steps:
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@v4
with:
artifact_name: java-evolution-pages
- name: Announce deploy URL
run: echo "Deployed to ${{ steps.deploy.outputs.page_url }}"