Skip to content

Commit 5813ca2

Browse files
authored
Initial commit
0 parents  commit 5813ca2

88 files changed

Lines changed: 5602 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "HugoBlox Codespace",
3+
"image": "ghcr.io/HugoBlox/hugo-blox-dev:hugo0.156.0",
4+
"updateContentCommand": "pnpm install --frozen-lockfile --prefer-offline",
5+
"postCreateCommand": "pnpm --version && hugo version",
6+
"customizations": {
7+
"vscode": {
8+
"extensions": [
9+
"ownable.ownable"
10+
]
11+
}
12+
},
13+
"mounts": [
14+
"source=pnpm-store,target=/home/vscode/.local/share/pnpm,type=volume"
15+
],
16+
"remoteUser": "vscode",
17+
"forwardPorts": [
18+
1313
19+
],
20+
"portsAttributes": {
21+
"1313": {
22+
"label": "Hugo Server"
23+
}
24+
}
25+
}

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: gcushen
2+
custom: https://hugoblox.com/sponsor/

.github/preview.webp

48.4 KB
Loading

.github/workflows/build.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Build
2+
3+
env:
4+
NODE_VERSION: '20'
5+
6+
on:
7+
# Standalone trigger for PR validation
8+
pull_request:
9+
branches: ['main']
10+
# Reusable workflow trigger - called by deploy.yml
11+
workflow_call:
12+
outputs:
13+
artifact-id:
14+
description: 'The ID of the uploaded artifact'
15+
value: ${{ jobs.build.outputs.artifact-id }}
16+
# Allow manual trigger for testing
17+
workflow_dispatch:
18+
19+
# Read-only permissions for security
20+
permissions:
21+
contents: read
22+
23+
# Prevent duplicate builds for the same PR
24+
concurrency:
25+
group: build-${{ github.head_ref || github.run_id }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
build:
30+
if: github.repository_owner != 'HugoBlox'
31+
runs-on: ubuntu-latest
32+
timeout-minutes: 10
33+
outputs:
34+
artifact-id: ${{ steps.upload.outputs.artifact-id }}
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
# Fetch history for Hugo's .GitInfo and .Lastmod
40+
fetch-depth: 0
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v6
44+
with:
45+
node-version: ${{ env.NODE_VERSION }}
46+
47+
- name: Setup pnpm
48+
if: hashFiles('package.json') != ''
49+
uses: pnpm/action-setup@v4
50+
51+
- name: Get Hugo Version
52+
id: hugo-version
53+
run: |
54+
# Install pinned yq version for robust YAML parsing
55+
YQ_VERSION="v4.44.1"
56+
if ! wget -q --tries=3 --waitretry=1 -O /tmp/yq \
57+
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"; then
58+
echo "::error::Failed to download yq"
59+
exit 1
60+
fi
61+
sudo mv /tmp/yq /usr/local/bin/yq
62+
sudo chmod +x /usr/local/bin/yq
63+
64+
# Read hugo_version from hugoblox.yaml
65+
VERSION=$(yq '.hugo_version // ""' hugoblox.yaml 2>/dev/null | grep -v '^null$' || true)
66+
67+
# Fallback to a known stable version if not specified
68+
DEFAULT_VERSION="0.154.5"
69+
VERSION=${VERSION:-$DEFAULT_VERSION}
70+
71+
# Validate version format (basic check)
72+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
73+
echo "::warning::Invalid hugo_version format '$VERSION', using default $DEFAULT_VERSION"
74+
VERSION="$DEFAULT_VERSION"
75+
fi
76+
77+
echo "HUGO_VERSION=$VERSION" >> $GITHUB_ENV
78+
echo "Using Hugo version: $VERSION"
79+
80+
- name: Install dependencies
81+
run: |
82+
# Install Tailwind CLI if package.json exists
83+
if [ -f "package.json" ]; then
84+
echo "Installing Tailwind dependencies..."
85+
pnpm install --no-frozen-lockfile || npm install
86+
fi
87+
88+
- name: Setup Hugo
89+
uses: peaceiris/actions-hugo@v3
90+
with:
91+
hugo-version: ${{ env.HUGO_VERSION }}
92+
extended: true
93+
94+
# Cache dependencies (Go modules, node_modules) - stable, rarely changes
95+
- uses: actions/cache@v4
96+
with:
97+
path: |
98+
/tmp/hugo_cache_runner/
99+
node_modules/
100+
modules/*/node_modules/
101+
key: ${{ runner.os }}-hugo-deps-${{ hashFiles('**/go.mod', '**/package-lock.json',
102+
'**/pnpm-lock.yaml') }}
103+
restore-keys: |
104+
${{ runner.os }}-hugo-deps-
105+
106+
# Cache Hugo resources (processed images, CSS) - invalidates only when assets/config change
107+
- uses: actions/cache@v4
108+
with:
109+
path: resources/
110+
key: ${{ runner.os }}-hugo-resources-${{ hashFiles('assets/**/*', 'config/**/*',
111+
'hugo.yaml', 'package.json') }}
112+
restore-keys: |
113+
${{ runner.os }}-hugo-resources-
114+
115+
- name: Build with Hugo
116+
env:
117+
HUGO_ENVIRONMENT: production
118+
HUGO_BLOX_LICENSE: ${{ secrets.HUGO_BLOX_LICENSE }}
119+
run: |
120+
echo "Hugo Cache Dir: $(hugo config | grep cachedir)"
121+
hugo --minify
122+
123+
- name: Generate Pagefind search index (if applicable)
124+
run: |
125+
# Check if site uses Pagefind search
126+
if [ -f "package.json" ] && grep -q "pagefind" package.json; then
127+
pnpm run pagefind || npx pagefind --site "public"
128+
fi
129+
130+
- name: Upload artifact
131+
id: upload
132+
uses: actions/upload-pages-artifact@v4
133+
with:
134+
path: ./public

.github/workflows/deploy.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Deploy website to GitHub Pages
2+
3+
on:
4+
# Trigger the workflow every time you push to the `main` branch
5+
push:
6+
branches: ['main']
7+
# Allows you to run this workflow manually from the Actions tab on GitHub
8+
workflow_dispatch:
9+
10+
# Provide permission to clone the repo and deploy it to GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: 'pages'
18+
cancel-in-progress: false
19+
20+
jobs:
21+
# Check deployment configuration
22+
config:
23+
if: github.repository_owner != 'HugoBlox'
24+
runs-on: ubuntu-latest
25+
outputs:
26+
deploy-host: ${{ steps.check.outputs.host }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
sparse-checkout: hugoblox.yaml
32+
sparse-checkout-cone-mode: false
33+
34+
- name: Check deploy host
35+
id: check
36+
run: |
37+
# Install pinned yq version for robust YAML parsing
38+
YQ_VERSION="v4.44.1"
39+
if ! wget -q --tries=3 --waitretry=1 -O /tmp/yq \
40+
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"; then
41+
echo "::error::Failed to download yq"
42+
exit 1
43+
fi
44+
sudo mv /tmp/yq /usr/local/bin/yq
45+
sudo chmod +x /usr/local/bin/yq
46+
47+
# Read deploy.host from hugoblox.yaml, default to github-pages
48+
HOST=$(yq '.deploy.host // ""' hugoblox.yaml 2>/dev/null | grep -v '^null$' || true)
49+
HOST=${HOST:-github-pages}
50+
51+
# Validate known hosts
52+
if [[ ! "$HOST" =~ ^(github-pages|netlify|vercel|cloudflare|none)$ ]]; then
53+
echo "::warning::Unknown deploy host '$HOST', defaulting to github-pages"
54+
HOST="github-pages"
55+
fi
56+
57+
echo "host=$HOST" >> $GITHUB_OUTPUT
58+
echo "Deployment target: $HOST"
59+
60+
# Build website using reusable workflow (always runs for CI)
61+
build:
62+
needs: config
63+
if: github.repository_owner != 'HugoBlox'
64+
uses: ./.github/workflows/build.yml
65+
secrets: inherit
66+
67+
# Deploy website to GitHub Pages hosting (only if configured)
68+
deploy:
69+
needs: [config, build]
70+
if: needs.config.outputs.deploy-host == 'github-pages'
71+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
72+
permissions:
73+
pages: write # to deploy to Pages
74+
id-token: write # to verify the deployment originates from an appropriate source
75+
# Deploy to the github-pages environment
76+
environment:
77+
name: github-pages
78+
url: ${{ steps.deployment.outputs.page_url }}
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Deploy to GitHub Pages
82+
id: deployment
83+
uses: actions/deploy-pages@v4
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Hugo Blox GitHub Action to convert Bibtex publications to Markdown-based webpages
2+
name: Import Publications From Bibtex
3+
4+
# Require permission to create a PR (least privilege principle)
5+
permissions:
6+
contents: write
7+
pull-requests: write
8+
9+
# Run workflow when a `.bib` file is added or updated in the `data/` folder
10+
on:
11+
push:
12+
branches: ['main']
13+
paths: ['publications.bib']
14+
15+
# Allows you to run this workflow manually from the Actions tab
16+
workflow_dispatch:
17+
18+
# Prevent concurrent runs of this workflow
19+
concurrency:
20+
group: import-publications-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
hugoblox:
25+
if: github.repository_owner != 'HugoBlox'
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 10
28+
29+
env:
30+
ACADEMIC_VERSION: '>=0.10.0'
31+
PYTHON_VERSION: '3.13'
32+
steps:
33+
- name: Checkout the repo
34+
uses: actions/checkout@v4
35+
with:
36+
# Only need recent history for publication import
37+
fetch-depth: 1
38+
39+
- name: Set up Python 3.13
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: '3.13'
43+
- name: Setup pip cache
44+
uses: actions/cache@v4
45+
with:
46+
path: ~/.cache/pip
47+
key: ${{ runner.os }}-pip-academic-${{ env.ACADEMIC_VERSION }}
48+
restore-keys: |
49+
${{ runner.os }}-pip-academic-
50+
${{ runner.os }}-pip-
51+
52+
- name: Install dependencies
53+
run: |
54+
python -m pip install --upgrade pip
55+
pip install "academic${{ env.ACADEMIC_VERSION }}"
56+
- name: Validate publications.bib file
57+
if: ${{ hashFiles('publications.bib') != '' }}
58+
run: |
59+
if [ ! -f "publications.bib" ]; then
60+
echo "❌ publications.bib file not found"
61+
exit 1
62+
fi
63+
echo "✅ publications.bib file found"
64+
65+
- name: Run Academic (Bibtex To Markdown Converter)
66+
# Check `.bib` file exists for case when action runs on `.bib` deletion
67+
# Note GH only provides hashFiles func in `steps.if` context, not `jobs.if` context
68+
if: ${{ hashFiles('publications.bib') != '' }}
69+
run: |
70+
echo "🚀 Starting publication import..."
71+
academic import publications.bib content/publication/ --compact --verbose
72+
echo "✅ Publication import completed successfully"
73+
74+
# Verify that files were created
75+
if [ -d "content/publication" ] && [ "$(ls -A content/publication/)" ]; then
76+
echo "📚 Publications imported: $(ls content/publication/ | wc -l) items"
77+
else
78+
echo "⚠️ No publications were imported"
79+
fi
80+
continue-on-error: false
81+
- name: Create Pull Request
82+
# Set ID for `Check outputs` stage
83+
id: cpr
84+
uses: peter-evans/create-pull-request@v6
85+
with:
86+
commit-message: 'feat(publications): import latest publications from bibtex'
87+
title: 'HugoBlox Kit - Import latest publications from Bibtex'
88+
body: |
89+
🔄 **Automated Publication Import**
90+
91+
This PR automatically imports the latest publications from `publications.bib` to `content/publication/`.
92+
93+
**Changes:**
94+
- 📚 Updated publication entries
95+
- 🏷️ Processed bibliographic data
96+
97+
---
98+
将最新的出版物从`publications.bib`导入到`content/publication/`。
99+
100+
📖 [View Documentation](https://github.com/GetRD/academic-file-converter)
101+
base: main
102+
labels: automated-pr, content, publications
103+
branch: hugoblox-import-publications-${{ github.run_id }}
104+
delete-branch: true
105+
draft: false
106+
- name: Check outputs
107+
if: ${{ steps.cpr.outputs.pull-request-number }}
108+
run: |
109+
echo "✅ Successfully created Pull Request!"
110+
echo "📝 Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
111+
echo "🔗 Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
112+
echo "🎯 Operation completed at $(date)"
113+
114+
- name: Report workflow status
115+
if: always()
116+
run: |
117+
if [ "${{ job.status }}" == "success" ]; then
118+
echo "🎉 Workflow completed successfully"
119+
else
120+
echo "❌ Workflow failed - check logs for details"
121+
exit 1
122+
fi
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Internal HugoBlox workflow - Updates README news section from RSS feed.
2+
# This file only runs on the HugoBlox org repo and can be safely deleted by end users.
3+
name: Internal - Update README News
4+
5+
on:
6+
schedule:
7+
- cron: 0 0 * * 0
8+
# Allows you to run this workflow manually from the Actions tab on GitHub.
9+
workflow_dispatch:
10+
11+
# Provide permission to clone the repo and deploy it to GitHub Pages
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
update:
17+
if: github.repository_owner == 'HugoBlox'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: HugoBlox/gh-action-updater@v2
21+
with:
22+
feed-url: https://hugoblox.com/rss.xml
23+
readme-section: news
24+
branch: main
25+
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)