Skip to content

Fix oDancingZombie logic to prevent errors when zombie is not present #169

Fix oDancingZombie logic to prevent errors when zombie is not present

Fix oDancingZombie logic to prevent errors when zombie is not present #169

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
deployments: write
concurrency:
group: "cloudflare-pages"
cancel-in-progress: false
jobs:
version-file-and-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: npm i -g oxlint oxfmt
- name: Beautify code
run: |
npm run fix || true
npx oxfmt --write . "**/*.{js,md,html,css,yml}"
- name: Create v.html with commit hash
run: |
echo "${{ github.sha }}" > game/images/Zombies/CX/v.html
- name: Get commit message & author email
id: get_commit_message
run: |
COMMIT_MSG=$(git log -1 --pretty=format:%s)
AUTHOR_EMAIL=$(git log -1 --pretty=format:%ae)
echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
echo "author_email=$AUTHOR_EMAIL" >> $GITHUB_OUTPUT
- name: Commit changes
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Format \"${{ steps.get_commit_message.outputs.message }}\"
Original commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
Co-authored-by: ${{ github.actor }} <${{ steps.get_commit_message.outputs.author_email }}>" || exit 0
git push
deploy:
runs-on: ubuntu-latest
needs: version-file-and-lint
steps:
- name: Checkout latest from main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Pull latest changes
run: git pull origin main
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install minification tools
run: |
npm install -g esbuild html-minifier-terser
- name: Minify JavaScript & CSS files
run: |
esbuild $(find . -type f \( -name "*.js" -o -name "*.css" \) -not -path "./node_modules/*") \
--minify \
--sourcemap \
--sources-content=true \
--outdir=. \
--allow-overwrite
- name: Minify HTML files
run: |
find . -type f -name "*.html" -not -path "./node_modules/*" | while read file; do
html-minifier-terser \
--collapse-whitespace \
--remove-comments \
--remove-tag-whitespace \
--minify-css true \
--minify-js true \
-o "$file" \
"$file"
done
- name: Deploy to Cloudflare Pages (Direct Upload)
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy . --project-name=pvz
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# discord-notify:
# runs-on: ubuntu-latest
# needs: [version-file-and-lint, deploy]
# if: always()
# steps:
# - name: Notify Discord
# uses: sarisia/actions-status-discord@v1
# if: always()
# with:
# webhook: ${{ secrets.DISCORD_WEBHOOK }}
# ack_no_webhook: true
# status: ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped')) && 'Failure' || contains(needs.*.result, 'cancelled') && 'Cancelled' || 'Success' }}
# title: ${{ github.workflow }}
# description: ${{ github.repository }} @ ${{ github.ref_name }}\n${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
# url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}