https://pvzm.net/ to play [Read-only GitHub mirror] pvzm.net
modded vs pvz plants-vs-zombies plantsvszombies javascript online zombie noads jspvz pvzm game plants plant
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

optimize build workflow

authored by

Clay and committed by
GitHub
e60cc8de c00d997e

+36 -61
+36 -61
.github/workflows/main.yml
··· 21 21 steps: 22 22 - name: Checkout repository 23 23 uses: actions/checkout@v4 24 + with: 25 + fetch-depth: 1 24 26 25 - - name: Setup Node.js 27 + - name: Setup Node.js & pnpm 26 28 uses: actions/setup-node@v3 27 29 with: 28 30 node-version: "lts/*" 29 31 32 + - name: Install pnpm 33 + run: corepack enable pnpm 34 + 35 + - name: Cache pnpm global packages 36 + uses: actions/cache@v4 37 + with: 38 + path: | 39 + ~/.local/share/pnpm/global 40 + ~/.local/share/pnpm/store 41 + key: pnpm-global-${{ hashFiles('.github/workflows/deploy.yml') }} 42 + restore-keys: pnpm-global- 43 + 30 44 - name: Install dependencies 31 - run: npm i -g oxlint oxfmt esbuild html-minifier-terser 45 + run: pnpm add -g oxlint oxfmt esbuild html-minifier-terser 32 46 33 - - name: Beautify code 47 + - name: Lint, format & version stamp 34 48 run: | 35 - npm run fix || true 36 - npx oxfmt --write . "**/*.{js,md,html,css,yml}" 37 - 38 - - name: Create v.html with commit hash 39 - run: | 49 + pnpm run fix || true 50 + pnpm oxfmt --write . "**/*.{js,md,html,css,yml}" 40 51 echo "${{ github.sha }}" > game/images/Zombies/CX/v.html 41 52 42 - - name: Get commit message & author email 43 - id: get_commit_message 53 + - name: Commit changes 44 54 run: | 45 55 COMMIT_MSG=$(git log -1 --pretty=format:%s) 46 56 AUTHOR_EMAIL=$(git log -1 --pretty=format:%ae) 47 - echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT 48 - echo "author_email=$AUTHOR_EMAIL" >> $GITHUB_OUTPUT 49 - 50 - - name: Commit changes 51 - run: | 52 57 git config user.name github-actions 53 58 git config user.email github-actions@github.com 54 59 git add . 55 - git commit -m "Format \"${{ steps.get_commit_message.outputs.message }}\" 60 + git commit -m "Format \"$COMMIT_MSG\" 56 61 Original commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }} 57 62 58 - Co-authored-by: ${{ github.actor }} <${{ steps.get_commit_message.outputs.author_email }}>" || exit 0 63 + Co-authored-by: ${{ github.actor }} <$AUTHOR_EMAIL>" || exit 0 59 64 git push 60 65 61 - - name: Bundle CPlants.js 66 + - name: Bundle & minify all assets 62 67 run: | 63 68 esbuild game/js/CPlants.js \ 64 - --bundle \ 65 - --minify \ 66 - --sourcemap \ 67 - --sources-content=true \ 68 - --outfile=game/js/CPlants.js \ 69 - --allow-overwrite 69 + --bundle --minify --sourcemap --sources-content=true \ 70 + --outfile=game/js/CPlants.js --allow-overwrite 71 + 72 + esbuild $(find . -type f \( -name "*.js" -o -name "*.css" \) \ 73 + -not -path "./node_modules/*" -not -name "CPlants.js") \ 74 + --minify --sourcemap --sources-content=true \ 75 + --outdir=. --allow-overwrite & 70 76 71 - - name: Minify JavaScript & CSS files 72 - run: | 73 - esbuild $(find . -type f \( -name "*.js" -o -name "*.css" \) -not -path "./node_modules/*") \ 74 - --minify \ 75 - --sourcemap \ 76 - --sources-content=true \ 77 - --outdir=. \ 78 - --allow-overwrite 77 + find . -type f -name "*.html" -not -path "./node_modules/*" | \ 78 + xargs -P4 -I{} html-minifier-terser \ 79 + --collapse-whitespace --remove-comments --remove-tag-whitespace \ 80 + --minify-css true --minify-js true -o {} {} & 79 81 80 - - name: Minify HTML files 81 - run: | 82 - find . -type f -name "*.html" -not -path "./node_modules/*" | while read file; do 83 - html-minifier-terser \ 84 - --collapse-whitespace \ 85 - --remove-comments \ 86 - --remove-tag-whitespace \ 87 - --minify-css true \ 88 - --minify-js true \ 89 - -o "$file" \ 90 - "$file" 91 - done 82 + wait 92 83 93 - - name: Deploy to Cloudflare Pages (Direct Upload) 84 + - name: Deploy to Cloudflare Pages 94 85 uses: cloudflare/wrangler-action@v3 95 86 with: 96 87 apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} 97 88 accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} 98 89 command: pages deploy . --project-name=pvz 99 90 gitHubToken: ${{ secrets.GITHUB_TOKEN }} 100 - 101 - # discord-notify: 102 - # runs-on: ubuntu-latest 103 - # needs: build-and-deploy 104 - # if: always() 105 - # steps: 106 - # - name: Notify Discord 107 - # uses: sarisia/actions-status-discord@v1 108 - # if: always() 109 - # with: 110 - # webhook: ${{ secrets.DISCORD_WEBHOOK }} 111 - # ack_no_webhook: true 112 - # status: ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped')) && 'Failure' || contains(needs.*.result, 'cancelled') && 'Cancelled' || 'Success' }} 113 - # title: ${{ github.workflow }} 114 - # description: ${{ github.repository }} @ ${{ github.ref_name }}\n${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} 115 - # url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}