Skip to content

Commit 253063a

Browse files
author
Splitter
committed
ci(starters): upgrade
1 parent 5344f35 commit 253063a

File tree

3 files changed

+163
-120
lines changed

3 files changed

+163
-120
lines changed

.github/workflows/deploy.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Deploy website to GitHub Pages
2+
3+
env:
4+
WC_HUGO_VERSION: '0.148.2'
5+
NODE_VERSION: '20'
6+
7+
on:
8+
# Trigger the workflow every time you push to the `main` branch
9+
push:
10+
branches: ['main']
11+
# Allows you to run this workflow manually from the Actions tab on GitHub.
12+
workflow_dispatch:
13+
14+
# Provide permission to clone the repo and deploy it to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
concurrency:
21+
group: 'pages'
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Build website
26+
build:
27+
if: github.repository_owner != 'HugoBlox'
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
# Fetch history for Hugo's .GitInfo and .Lastmod
34+
fetch-depth: 0
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: ${{ env.NODE_VERSION }}
40+
41+
- name: Setup pnpm
42+
if: hashFiles('package.json') != ''
43+
uses: pnpm/action-setup@v4
44+
45+
- name: Install dependencies
46+
run: |
47+
# Install Tailwind CLI if package.json exists
48+
if [ -f "package.json" ]; then
49+
echo "Installing Tailwind dependencies..."
50+
pnpm install || npm install
51+
fi
52+
53+
- name: Setup Hugo
54+
uses: peaceiris/actions-hugo@v3
55+
with:
56+
hugo-version: ${{ env.WC_HUGO_VERSION }}
57+
extended: true
58+
59+
- uses: actions/cache@v4
60+
with:
61+
path: |
62+
/tmp/hugo_cache_runner/
63+
node_modules/
64+
modules/*/node_modules/
65+
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.mod', '**/package-lock.json', '**/pnpm-lock.yaml') }}
66+
restore-keys: |
67+
${{ runner.os }}-hugomod-
68+
69+
- name: Setup Pages
70+
id: pages
71+
uses: actions/configure-pages@v5
72+
73+
- name: Build with Hugo
74+
env:
75+
HUGO_ENVIRONMENT: production
76+
run: |
77+
echo "Hugo Cache Dir: $(hugo config | grep cachedir)"
78+
hugo --minify --baseURL "${{ steps.pages.outputs.base_url }}/"
79+
80+
- name: Generate Pagefind search index (if applicable)
81+
run: |
82+
# Check if site uses Pagefind
83+
if [ -f "package.json" ] && grep -q "pagefind" package.json; then
84+
pnpm dlx pagefind --source "public" || npx pagefind --source "public"
85+
elif [ -f "netlify.toml" ] && grep -q "pagefind" netlify.toml; then
86+
pnpm dlx pagefind --source "public" || npx pagefind --source "public"
87+
fi
88+
89+
- name: Upload artifact
90+
uses: actions/upload-pages-artifact@v4
91+
with:
92+
path: ./public
93+
94+
# Deploy website to GitHub Pages hosting
95+
deploy:
96+
if: github.repository_owner != 'HugoBlox'
97+
environment:
98+
name: github-pages
99+
url: ${{ steps.deployment.outputs.page_url }}
100+
runs-on: ubuntu-latest
101+
needs: build
102+
steps:
103+
- name: Deploy to GitHub Pages
104+
id: deployment
105+
uses: actions/deploy-pages@v4
Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Hugo Blox GitHub Action to convert Bibtex publications to Markdown-based webpages
22
name: Import Publications From Bibtex
33

4-
# Require permission to create a PR
4+
# Require permission to create a PR (least privilege principle)
55
permissions:
66
contents: write
77
pull-requests: write
8+
metadata: read
89

910
# Run workflow when a `.bib` file is added or updated in the `data/` folder
1011
on:
@@ -19,39 +20,81 @@ jobs:
1920
hugoblox:
2021
if: github.repository_owner != 'HugoBlox'
2122
runs-on: ubuntu-latest
23+
timeout-minutes: 10
24+
25+
env:
26+
ACADEMIC_VERSION: '>=0.10.0'
2227
steps:
2328
- name: Checkout the repo
24-
uses: actions/checkout@v3
25-
- name: Set up Python 3.12
26-
uses: actions/setup-python@v4
29+
uses: actions/checkout@v4
30+
with:
31+
# Fetch history for better performance and debugging
32+
fetch-depth: 0
33+
34+
- name: Set up Python 3.13
35+
uses: actions/setup-python@v5
2736
with:
28-
python-version: "3.12"
37+
python-version: '3.13'
38+
- name: Setup pip cache
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.cache/pip
42+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
43+
restore-keys: |
44+
${{ runner.os }}-pip-
45+
2946
- name: Install dependencies
3047
run: |
3148
python -m pip install --upgrade pip
32-
pip install academic==0.10.0
49+
pip install academic${{ env.ACADEMIC_VERSION }}
3350
- name: Run Academic (Bibtex To Markdown Converter)
3451
# Check `.bib` file exists for case when action runs on `.bib` deletion
3552
# Note GH only provides hashFiles func in `steps.if` context, not `jobs.if` context
3653
if: ${{ hashFiles('publications.bib') != '' }}
37-
run: academic import publications.bib content/publication/ --compact
54+
run: |
55+
echo "Starting publication import..."
56+
academic import publications.bib content/publication/ --compact
57+
echo "Publication import completed successfully"
58+
continue-on-error: false
3859
- name: Create Pull Request
3960
# Set ID for `Check outputs` stage
4061
id: cpr
41-
uses: peter-evans/create-pull-request@v5
62+
uses: peter-evans/create-pull-request@v6
4263
with:
43-
commit-message: 'content: import publications from Bibtex'
44-
title: Hugo Blox Builder - Import latest publications
64+
commit-message: 'content(publications): run Hugo Blox importer to import publications from Bibtex'
65+
title: 'Hugo Blox Builder - Import latest publications from Bibtex'
4566
body: |
46-
Import the latest publications from `publications.bib` to `content/publication/`.
67+
🔄 **Automated Publication Import**
68+
69+
This PR automatically imports the latest publications from `publications.bib` to `content/publication/`.
70+
71+
**Changes:**
72+
- 📚 Updated publication entries
73+
- 🏷️ Processed bibliographic data
74+
75+
---
4776
将最新的出版物从`publications.bib`导入到`content/publication/`。
48-
[View Documentation](https://github.com/GetRD/academic-file-converter)
77+
78+
📖 [View Documentation](https://github.com/GetRD/academic-file-converter)
4979
base: main
50-
labels: automated-pr, content
80+
labels: automated-pr, content, publications
5181
branch: hugoblox-import-publications
5282
delete-branch: true
83+
draft: false
5384
- name: Check outputs
5485
if: ${{ steps.cpr.outputs.pull-request-number }}
5586
run: |
56-
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
57-
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
87+
echo "✅ Successfully created Pull Request!"
88+
echo "📝 Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
89+
echo "🔗 Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
90+
echo "🎯 Operation completed at $(date)"
91+
92+
- name: Report workflow status
93+
if: always()
94+
run: |
95+
if [ "${{ job.status }}" == "success" ]; then
96+
echo "🎉 Workflow completed successfully"
97+
else
98+
echo "❌ Workflow failed - check logs for details"
99+
exit 1
100+
fi

.github/workflows/publish.yaml

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)