-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (106 loc) · 3.55 KB
/
jekyll-gh-pages.yml
File metadata and controls
120 lines (106 loc) · 3.55 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
114
115
116
117
118
119
120
# .github/workflows/jekyll-pages.yml
name: Deploy Jekyll with GitHub Pages (robust)
on:
push:
branches: [ main, master ]
workflow_dispatch: {}
schedule:
# Daily at 3:00 AM IST (21:30 UTC previous day)
- cron: "30 21 * * *"
# Least privilege for Pages
permissions:
contents: read
pages: write
id-token: write
# Prevent overlapping deploys per ref
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
# 🚫 Never run from forks / external PRs
if: >
github.repository == 'Someshdiwan/JavaEvolution-Learning-Growing-Mastering' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
name: Build site (Jekyll)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Detect Gemfile location
id: detect
shell: bash
run: |
if [ -f "site/Gemfile" ]; then
echo "gem_dir=site" >> "$GITHUB_OUTPUT"
echo "Found Gemfile in site/"
elif [ -f "Gemfile" ]; then
echo "gem_dir=." >> "$GITHUB_OUTPUT"
echo "Found Gemfile in repo root"
else
echo "gem_dir=NONE" >> "$GITHUB_OUTPUT"
echo "No Gemfile found; will use jekyll-build-pages fallback."
fi
# Fast path: use the repo's Gemfile (caches automatically)
- name: Setup Ruby (bundler cache)
if: ${{ steps.detect.outputs.gem_dir != 'NONE' }}
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
# cache & install are scoped to where the Gemfile lives
working-directory: ${{ steps.detect.outputs.gem_dir }}
- name: Build with bundle exec
if: ${{ steps.detect.outputs.gem_dir != 'NONE' }}
working-directory: ${{ steps.detect.outputs.gem_dir }}
env:
JEKYLL_ENV: production
shell: bash
run: |
echo "Building Jekyll from $(pwd)…"
bundle exec jekyll build --source . --destination "${GITHUB_WORKSPACE}/_site"
# Fallback: no Gemfile; use the official builder (looks in ./site by default)
- name: Build with actions/jekyll-build-pages (fallback)
if: ${{ steps.detect.outputs.gem_dir == 'NONE' }}
uses: actions/jekyll-build-pages@v1
with:
source: ./site
destination: ./_site
- name: Validate _site exists
shell: bash
run: |
if [ ! -d "_site" ]; then
echo "::error::_site was not generated."
ls -la
exit 1
fi
echo "✅ _site generated."
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./_site
name: java-evolution-pages
deploy:
# 🚫 Never run from forks / external PRs
if: >
github.repository == 'Someshdiwan/JavaEvolution-Learning-Growing-Mastering' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
name: Deploy to GitHub Pages
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
with:
artifact_name: java-evolution-pages
- name: Show URL
run: echo "Deployed to ${{ steps.deployment.outputs.page_url }}"