diff --git a/.github/workflows/cf-pages.yaml b/.github/workflows/cf-pages.yaml index 4443ca7..a176988 100644 --- a/.github/workflows/cf-pages.yaml +++ b/.github/workflows/cf-pages.yaml @@ -4,17 +4,44 @@ on: push: branches: [ main ] +env: + CACHE_ZIP_FILENAME: cache.zip + ASSETS_FOLDER: data/operator + RELEASE_FOLDER: release + CACHE_BASE_KEY: akassets + jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Use PNPM - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 with: version: latest + run_install: false + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: latest + cache: 'pnpm' - name: Install dependencies run: pnpm i + - name: Restore cached assets + id: cache-akassets-restore + uses: actions/cache@v4 + with: + path: | + ${{ env.CACHE_ZIP_FILENAME }} + key: ${{ env.CACHE_BASE_KEY }}-${{ hashFiles('offical_update.json') }} + restore-keys: | + ${{ env.CACHE_BASE_KEY }} + - name: Unzip assets + run: | + if test -f ${{ env.CACHE_ZIP_FILENAME }}; then + unzip -qq ${{ env.CACHE_ZIP_FILENAME }} -d . + fi + shell: bash - name: Download Assets run: pnpm run cf:download - name: Build all @@ -27,5 +54,14 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} projectName: aklive2d - directory: release + directory: ${{ env.RELEASE_FOLDER}} wranglerVersion: '3' + - name: Zip assets + run: zip -qq -9 -r ${{ env.CACHE_ZIP_FILENAME }} ${{ env.ASSETS_FOLDER }} + - name: Save assets + id: cache-akassets-save + uses: actions/cache/save@v4 + with: + path: | + ${{ env.CACHE_ZIP_FILENAME }} + key: ${{ env.CACHE_BASE_KEY }}-${{ hashFiles('offical_update.json') }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 5011bb0..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,69 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ main ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/update-charwords.yaml b/.github/workflows/update-charwords.yaml index 8f600e8..0a6105a 100644 --- a/.github/workflows/update-charwords.yaml +++ b/.github/workflows/update-charwords.yaml @@ -15,9 +15,15 @@ jobs: steps: - uses: actions/checkout@v3 - name: Use PNPM - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 with: version: latest + run_install: false + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: latest + cache: 'pnpm' - name: Install dependencies run: pnpm i - name: Update charwords diff --git a/.github/workflows/update-music.yaml b/.github/workflows/update-music.yaml index acca99f..242ed7b 100644 --- a/.github/workflows/update-music.yaml +++ b/.github/workflows/update-music.yaml @@ -15,9 +15,15 @@ jobs: steps: - uses: actions/checkout@v3 - name: Use PNPM - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 with: version: latest + run_install: false + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: latest + cache: 'pnpm' - name: Install dependencies run: pnpm i - name: Update music mapping diff --git a/.github/workflows/update-offical-dyn-info.yaml b/.github/workflows/update-offical-dyn-info.yaml index 79c1e7e..6482d10 100644 --- a/.github/workflows/update-offical-dyn-info.yaml +++ b/.github/workflows/update-offical-dyn-info.yaml @@ -15,9 +15,15 @@ jobs: steps: - uses: actions/checkout@v3 - name: Use PNPM - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 with: version: latest + run_install: false + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: latest + cache: 'pnpm' - name: Install dependencies run: pnpm i - name: Update offical dyn info diff --git a/libs/cf_pages.js b/libs/cf_pages.js index 6a705ff..8c4abb7 100644 --- a/libs/cf_pages.js +++ b/libs/cf_pages.js @@ -5,7 +5,7 @@ import crypto from 'crypto'; import pThrottle from 'p-throttle'; import { spawnSync } from 'child_process'; import { readdirSync, fileTypeSync, writeSync, mkdir, exists } from './file.js'; - +//TODO: Utilizing github actions to upload base.zip and update.zip export default class CFPages { #uploadPath = path.join(__projectRoot, __config.folder.operator_data); #downloadPath = path.join(__projectRoot, __config.folder.operator_data); @@ -25,13 +25,13 @@ export default class CFPages { const indexFile = `${__config.akassets_url}/index.json` const resp = await fetch(indexFile); const data = await resp.json(); - mkdir(this.#downloadPath); + if (!exists(this.#downloadPath)) mkdir(this.#downloadPath); let list = data.children.flatMap((child) => { return this.#generateDownloadList(child, this.#downloadPath); }); const throttle = pThrottle({ limit: 10, - interval: 500 + interval: 100 }) while (list.length > 0) { const retry = []; @@ -42,7 +42,7 @@ export default class CFPages { const hash = await this.#getHash(file.target); if (hash === file.hash) { isExists = true - console.log("File already exists and hash matches:", suppressedPath); + // console.log("File already exists and hash matches:", suppressedPath); } } if (!isExists) {