Split Fonts #7
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: 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:]') | |
cn-font-split -i=./tmp/$i -o=./fonts/$font_name --renameOutputFont='[index][ext]' | |
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 |