Skip to content

Commit

Permalink
ci(update): cache fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
lengyanyu258 committed Jul 18, 2024
1 parent 5b50ab3 commit 7665a4a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 32 deletions.
34 changes: 8 additions & 26 deletions .github/actions/auto-update.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
name: Auto Update & Commit
description: "下载字体文件并执行脚本更新之后自动提交更改"
description: "缓存字体文件并执行脚本更新之后自动提交更改"

runs:
using: "composite"
steps:
- name: Download Sarasa Gothic Mono Slab SC TTF Release Asset
id: download_7z
uses: robinraju/[email protected]
- uses: actions/cache@v4
id: cache-fonts
with:
# The source repository path.
# Expected format {owner}/{repo}
# Default: ${{ github.repository }}
repository: "be5invis/Sarasa-Gothic"
path: tmp
key: SarasaMonoSlabSC-TTF-Unhinted-fonts-cache

# A flag to set the download target as latest release
# The default value is 'false'
latest: true

# The name of the file to download.
# Use this field only to specify filenames other than tarball or zipball, if any.
# Supports wildcard pattern (eg: '*', '*.deb', '*.zip' etc..)
fileName: "SarasaMonoSlabSC-TTF-Unhinted-*.7z"

# Relative path under $GITHUB_WORKSPACE to place the downloaded file(s)
# It will create the target directory automatically if not present
# eg: out-file-path: "my-downloads" => It will create directory $GITHUB_WORKSPACE/my-downloads
out-file-path: "tmp"

- name: Extract downloaded 7z file Asset
shell: bash
# p7zip-full is already the newest version (ubuntu-latest).
run: 7z x -t7z -otmp ${{ fromJson(steps.download_7z.outputs.downloaded_files)[0] }}
- name: Download Fonts (if not cached)
if: steps.cache-fonts.outputs.cache-hit != 'true'
uses: ./.github/actions/download-fonts

- run: poetry run python main.py --all --auto_update --publish

Expand Down
33 changes: 33 additions & 0 deletions .github/actions/download-fonts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Download & Extract Fonts
description: "下载字体文件"

runs:
using: "composite"
steps:
- name: Download Sarasa Gothic Mono Slab SC TTF Release Asset
id: download_7z
uses: robinraju/[email protected]
with:
# The source repository path.
# Expected format {owner}/{repo}
# Default: ${{ github.repository }}
repository: "be5invis/Sarasa-Gothic"

# A flag to set the download target as latest release
# The default value is 'false'
latest: true

# The name of the file to download.
# Use this field only to specify filenames other than tarball or zipball, if any.
# Supports wildcard pattern (eg: '*', '*.deb', '*.zip' etc..)
fileName: "SarasaMonoSlabSC-TTF-Unhinted-*.7z"

# Relative path under $GITHUB_WORKSPACE to place the downloaded file(s)
# It will create the target directory automatically if not present
# eg: out-file-path: "my-downloads" => It will create directory $GITHUB_WORKSPACE/my-downloads
out-file-path: "tmp"

- name: Extract downloaded 7z file Asset
shell: bash
# p7zip-full is already the newest version (ubuntu-latest).
run: 7z x -t7z -otmp ${{ fromJson(steps.download_7z.outputs.downloaded_files)[0] }}
9 changes: 4 additions & 5 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ jobs:
with:
python-version: "3.11"
cache: "poetry"
- name: Install Poetry Dependences.
run: poetry install
- run: poetry install

- name: Test if need update
- name: Test if need to update
id: test_update
run: poetry run python main.py --all --auto_update --test_update --no_dump

- if: steps.test_update.outputs.test_update == 'True'
name: Auto update data
- name: Proceed to update data
if: steps.test_update.outputs.test_update == 'True'
uses: ./.github/actions/auto-update
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ def manipulate(game_data: GameData):

# Used by GitHub Actions
if args.auto_update:
if not game_data.need_update:
if game_data.need_update:
print("Need to update!")
else:
print("No need to update!")

if args.test_update:
Expand Down

0 comments on commit 7665a4a

Please sign in to comment.