This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Convert Markdown to PDF and Release | |
on: | |
push: | |
branches: | |
- release-pdf | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # 确保对内容有写权限 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Update apt-get | |
run: sudo apt-get update | |
- name: Install pandoc | |
run: sudo apt-get install -y pandoc | |
- name: Install latex with xelatex | |
run: sudo apt-get install -y texlive-base texlive-xetex | |
- name: Install additional latex packages | |
run: sudo apt-get install -y texlive-latex-extra | |
- name: Install ctex | |
run: sudo apt-get install -y texlive-lang-chinese | |
- name: Install fonts | |
run: sudo apt-get install -y texlive-fonts-recommended texlive-fonts-extra ttf-mscorefonts-installer | |
- name: Convert Markdown to PDF with xelatex | |
run: | | |
mkdir -p pdfs | |
find . -path "./Excalidraw" -prune -o -name "*.md" -print | while IFS= read -r file; do | |
echo "Converting $file to PDF..." | |
pandoc "$file" --resource-path=$(dirname $file):$(dirname $file)/assets -o "pdfs/$(basename "$file" .md).pdf" --pdf-engine=xelatex --template=$PWD/template/my_template.latex | |
done | |
- name: List PDFs | |
run: ls -l pdfs | |
- name: Zip PDFs | |
run: zip -r pdfs.zip pdfs | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v1.0.4 | |
release_name: Release v1.0.4 | |
body: | | |
This is the release description. | |
draft: false | |
prerelease: false | |
- name: Upload PDFs to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: pdfs.zip | |
asset_name: pdfs.zip | |
asset_content_type: application/zip |