Skip to content

Split Fonts

Split Fonts #10

Workflow file for this run

name: Split Fonts
on:
workflow_dispatch:
jobs:
build:
name: get the fonts
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
node-version: '>=18.0.0'
- name: Download fonts
id: down
uses: robinraju/[email protected]
with:
repository: lxgw/LxgwWenKai
latest: true
out-file-path: "tmp"
- name: Split fonts
run: |
npm install cn-font-split -g
rm -rf ./fonts/
rm -rf ./style.css
rm -rf ./VERSION
for i in $(echo "$(ls ./tmp)" | grep -i '\.ttf$')
do
font_name=$(echo "$i" | sed -E 's/(.+)\.ttf$/\1/i' | tr '[:upper:]' '[:lower:]')
case "$font_name" in
*regular)
font_weight="400"
;;
*light)
font_weight="300"
;;
*bold)
font_weight="700"
;;
*medium)
font_weight="500"
;;
*)
font_weight="400"
;;
esac
cn-font-split -i=./tmp/$i -o=./fonts/$font_name --renameOutputFont='[index][ext]' --css.fontWeight=$font_weight
echo "@import url('./$font_name/result.css');" >> ./style.css
done
echo "${{ steps.down.outputs.tag_name }}" >> VERSION
mv VERSION fonts/VERSION
mv style.css fonts/style.css
rm -rf ./tmp/
- name: Auto Minify
uses: nizarmah/[email protected]
- name: Commit files
run: |
mv index.html fonts/index.html
cd fonts || exit 1
git init
git config user.email github-actions[bot]@users.noreply.github.com
git config user.name github-actions[bot]
git checkout -b latest
git status
git add .
git commit -m "update ${{ steps.down.outputs.tag_name }}" -a
git tag ${{ steps.down.outputs.tag_name }}
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
tags: true
directory: fonts
branch: latest