Skip to content

also pub zip

also pub zip #32

name: Generate Release PDF
# 感谢 Derived Cat (@hooyuser) 提供的自动发布小脚本!
on:
push:
branches:
- main
paths-ignore:
- '.gitignore'
env:
MIRROR_SITE_URL: https://142857.red/files
MIRROR_SITE_HOOK: https://142857.red/hooks/update_cppguidebook
MIRROR_SITE_TOKEN: ${{ secrets.SEVEN_TOKEN }}
jobs:
build_mkdocs:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set up Git repository
uses: actions/checkout@v4
- name: Prepare Mkdocs environment
run: |
pip install mkdocs
pip install mkdocs-print-site-plugin
pip install mkdocs-macros-plugin
- name: Compile Mkdocs document
run: |
mkdocs build
- name: Prepare Puppeteer environment
run: |
npm install puppeteer
- name: Compile PDF document
run: |
node misc/export_to_pdf.js file://$PWD/site/print_page/index.html cppguidebook.pdf "小彭老师的现代 C++ 大典"
du -h cppguidebook.pdf
- name: Generate ZIP site
run: |
zip -r cppguidebook-site.zip site
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
- name: Delete old Release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo
try {
const { data: { id } } = await github.rest.repos.getLatestRelease({ owner, repo })
await github.rest.repos.deleteRelease({ owner, repo, release_id: id })
} catch {}
- name: Generate release tag
id: tag
run: |
echo "release_date=$(date +"%Y 年 %m 月 %d 日 %H 点 %M 分")" >> $GITHUB_OUTPUT
echo "release_tag=latest_$(date +"%Y-%m-%d_%H-%M")" >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v2
with:
name: 伟大,无需多言
body: |
小彭老师发布的最新 C++ 大典,更新时间 ${{ steps.tag.outputs.release_date }}
> GitHub 卡顿,无法下载?访问 [小彭老师自己维护的镜像](${{ env.MIRROR_SITE_URL }}/cppguidebook.pdf)。
> 喜欢在线阅读?访问 [GitHub Pages](https://parallel101.github.io/cppguidebook)
tag_name: ${{ steps.tag.outputs.release_tag }}
files:
- cppguidebook.pdf

Check failure on line 81 in .github/workflows/generate_release_pdf.yml

View workflow run for this annotation

GitHub Actions / Generate Release PDF

Invalid workflow file

The workflow is not valid. .github/workflows/generate_release_pdf.yml (Line: 81, Col: 13): A sequence was not expected
- cppguidebook-site.zip
- name: Publish to mirror site
continue-on-error: true
run: |
curl -L -X POST ${{ env.MIRROR_SITE_HOOK }} -d token=${{ env.MIRROR_SITE_TOKEN }} -d tag=${{ steps.tag.outputs.release_tag }}