chore: update latest CN game data commit SHA #293
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: Deploy SSG to Cloudflare Pages | |
on: | |
# Runs on pushes targeting all branches | |
# The main branch is for production, others for preview | |
# Comment out when using Cloudflare's own automatic deployments | |
push: | |
# Allows running this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow the Cloudflare Pages action to create a Deployment | |
permissions: | |
contents: read | |
deployments: write | |
# Allow one concurrent deployment | |
# Ref is included in the group because Cloudflare can host multiple branches | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# Build and deploy job | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Checkout CN game data | |
uses: actions/checkout@v3 | |
with: | |
repository: Kengxxiao/ArknightsGameData | |
path: ArknightsGameData | |
- name: Checkout Yostar game data | |
uses: actions/checkout@v3 | |
with: | |
repository: Kengxxiao/ArknightsGameData_YoStar | |
path: ArknightsGameData_YoStar | |
- name: Set environment variables | |
run: | | |
echo "CN_GAME_DATA_ROOT_PATH=$(echo $GITHUB_WORKSPACE)/ArknightsGameData" >> $GITHUB_ENV | |
echo "YOSTAR_GAME_DATA_ROOT_PATH=$(echo $GITHUB_WORKSPACE)/ArknightsGameData_YoStar" >> $GITHUB_ENV | |
echo "ENABLE_SSR=true" >> $GITHUB_ENV | |
echo "NUXT_PUBLIC_FULL_BASE_URL=https://dataknights.pages.dev" >> $GITHUB_ENV | |
echo "NUXT_PUBLIC_COMMIT_BASE_URL=https://github.com/MusicOnline/AK-Dataknights/commit" >> $GITHUB_ENV | |
- name: Detect package manager | |
id: detect-package-manager | |
run: | | |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then | |
echo "manager=yarn" >> $GITHUB_OUTPUT | |
echo "command=install" >> $GITHUB_OUTPUT | |
exit 0 | |
elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then | |
echo "manager=pnpm" >> $GITHUB_OUTPUT | |
echo "command=install" >> $GITHUB_OUTPUT | |
exit 0 | |
elif [ -f "${{ github.workspace }}/package.json" ]; then | |
echo "manager=npm" >> $GITHUB_OUTPUT | |
echo "command=ci" >> $GITHUB_OUTPUT | |
exit 0 | |
else | |
echo "Unable to determine packager manager" | |
exit 1 | |
fi | |
# Must be done before Setup Node | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
if: ${{ steps.detect-package-manager.outputs.manager == 'pnpm' }} | |
with: | |
version: latest | |
run_install: false | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: ${{ steps.detect-package-manager.outputs.manager }} | |
- name: Restore cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
dist | |
.nuxt | |
key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }} | |
restore-keys: | | |
${{ runner.os }}-nuxt-build- | |
- name: Install dependencies | |
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} | |
- name: Prepare nuxt (postinstall) | |
run: ${{ steps.detect-package-manager.outputs.manager }} run prepare-nuxt | |
- name: Generate static site | |
run: ${{ steps.detect-package-manager.outputs.manager }} run generate | |
env: | |
NODE_OPTIONS: --max_old_space_size=8192 | |
NITRO_PRESET: static | |
- name: Deploy to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: dataknights | |
directory: .output/public | |
# Optional: Enable this to have GitHub Deployments triggered | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: Zip artifact for upload | |
run: zip output.zip .output/public/* -r | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cloudflare-pages | |
path: output.zip |