starters: auto-import publications from Bibtex

This commit is contained in:
Splitter
2023-10-29 09:24:01 +00:00
parent 30b3be037d
commit a954a0fcb0
5 changed files with 95 additions and 35 deletions

View File

@@ -0,0 +1,57 @@
# Wowchemy GitHub Action to convert Bibtex publications to Markdown-based webpages
name: Import Publications From Bibtex
# Require permission to create a PR
permissions:
contents: write
pull-requests: write
# Run workflow when a `.bib` file is added or updated in the `data/` folder
on:
push:
branches: ['main']
paths: ['publications.bib']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
wowchemy:
if: github.repository_owner != 'wowchemy'
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install academic==0.10.0
- name: Run Academic (Bibtex To Markdown Converter)
# Check `.bib` file exists for case when action runs on `.bib` deletion
# Note GH only provides hashFiles func in `steps.if` context, not `jobs.if` context
if: ${{ hashFiles('publications.bib') != '' }}
run: academic import publications.bib content/publication/ --compact
- name: Create Pull Request
# Set ID for `Check outputs` stage
id: cpr
uses: peter-evans/create-pull-request@v5
with:
commit-message: 'content: import publications from Bibtex'
title: Wowchemy - Import latest publications
body: |
Import the latest publications from `publications.bib` to `content/publication/`.
将最新的出版物从`publications.bib`导入到`content/publication/`。
[View Documentation](https://github.com/wowchemy/bibtex-to-markdown)
base: main
labels: automated-pr, content
branch: wowchemy-import-publications
delete-branch: true
- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

View File

@@ -1,5 +1,8 @@
name: Deploy Wowchemy website to GitHub Pages
env:
WC_HUGO_VERSION: '0.119.0'
on:
# Trigger the workflow every time you push to the `main` branch
push:
@@ -17,10 +20,6 @@ concurrency:
group: "pages"
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
# Build website
build:
@@ -32,20 +31,25 @@ jobs:
with:
# Fetch history for Hugo's .GitInfo and .Lastmod
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.119.0'
hugo-version: ${{ env.WC_HUGO_VERSION }}
extended: true
- uses: actions/cache@v3
with:
path: /tmp/hugo_cache_runner/
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-hugomod-
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Build with Hugo
env:
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
echo "Hugo Cache Dir: $(hugo config | grep cachedir)"
hugo --minify --baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v2