Skip to content

Commit d73cb07

Browse files
committed
ci(pages): update GitHub Actions to artifact-v4-compatible workflow
Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent 98563df commit d73cb07

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

.github/workflows/jekyll-gh-pages.yml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: "Deploy Jekyll with GitHub Pages (robust & artifact-v4 compatible)"
1+
name: "Deploy Jekyll with GitHub Pages (robust: Gemfile auto-detect)"
22

33
on:
44
push:
55
branches:
6-
- master
76
- main
7+
- master
88
workflow_dispatch: {}
99
schedule:
10-
- cron: '0 12 * * *' # daily at 12:00 UTC (adjust as needed)
10+
- cron: '0 12 * * *'
1111

1212
permissions:
1313
contents: read
@@ -29,30 +29,59 @@ jobs:
2929
submodules: true
3030
fetch-depth: 0
3131

32-
- name: Set up Ruby (for Jekyll)
32+
- name: Detect Gemfile location
33+
id: gemfile
34+
run: |
35+
# Prefer site/Gemfile if it exists
36+
if [ -f "site/Gemfile" ]; then
37+
echo "gemfile_dir=site" >> $GITHUB_OUTPUT
38+
echo "Found Gemfile in site/ directory."
39+
elif [ -f "Gemfile" ]; then
40+
echo "gemfile_dir=." >> $GITHUB_OUTPUT
41+
echo "Found Gemfile in repo root."
42+
else
43+
echo "No Gemfile found in repo root or site/ — failing early."
44+
ls -la
45+
exit 2
46+
fi
47+
48+
- name: Setup Ruby (for Jekyll)
3349
uses: ruby/setup-ruby@v1
3450
with:
3551
ruby-version: '3.2'
36-
bundler-cache: true
52+
bundler-cache: false # we use explicit cache step below
3753

38-
- name: Cache bundler gems
54+
- name: Cache bundler gems (auto target)
3955
uses: actions/cache@v4
56+
id: cache-bundler
4057
with:
4158
path: vendor/bundle
42-
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
59+
# If Gemfile.lock is under site/, use that; else root path is used.
60+
key: ${{ runner.os }}-gems-${{ steps.gemfile.outputs.gemfile_dir }}-${{ hashFiles(format('{0}/Gemfile.lock', steps.gemfile.outputs.gemfile_dir)) }}
4361
restore-keys: |
44-
${{ runner.os }}-gems-
62+
${{ runner.os }}-gems-${{ steps.gemfile.outputs.gemfile_dir }}-
4563
46-
- name: Install dependencies
64+
- name: Install Ruby gems (bundle install)
4765
run: |
66+
echo "Using Gemfile from: ${{ steps.gemfile.outputs.gemfile_dir }}"
67+
cd ${{ steps.gemfile.outputs.gemfile_dir }}
4868
bundle config set --local path 'vendor/bundle'
4969
bundle install --jobs 4 --retry 3
70+
shell: bash
5071

5172
- name: Build Jekyll site
5273
run: |
53-
bundle exec jekyll build --source site --destination _site
74+
echo "Building Jekyll from site/ to _site/"
75+
# If your Jekyll source is in 'site', build from there; otherwise build from repository root.
76+
if [ "${{ steps.gemfile.outputs.gemfile_dir }}" = "site" ]; then
77+
cd site
78+
bundle exec jekyll build --source . --destination ../_site
79+
else
80+
bundle exec jekyll build --source site --destination _site || bundle exec jekyll build --destination _site
81+
fi
5482
env:
5583
JEKYLL_ENV: production
84+
shell: bash
5685

5786
- name: Validate build
5887
run: |
@@ -61,7 +90,6 @@ jobs:
6190
exit 1
6291
fi
6392
64-
# Use upload-pages-artifact v3 (recent) which is compatible with artifact v4 backend
6593
- name: Upload Pages artifact
6694
uses: actions/upload-pages-artifact@v3
6795
with:
@@ -82,5 +110,4 @@ jobs:
82110
artifact_name: java-evolution-pages
83111

84112
- name: Announce deploy URL
85-
run: |
86-
echo "Deployed to ${{ steps.deploy.outputs.page_url }}"
113+
run: echo "Deployed to ${{ steps.deploy.outputs.page_url }}"

0 commit comments

Comments
 (0)