https://imgur.com/a/RrqreaX #99
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "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 ci | |
| - name: Beautify code | |
| run: | | |
| npm run fix || true | |
| npx prettier --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 | |
| id: get_commit_message | |
| run: | | |
| COMMIT_MSG=$(git log -1 --pretty=format:%s) | |
| echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT | |
| - name: Commit changes | |
| run: | | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| git add . | |
| git commit -m "${{ github.actor }} - ${{ steps.get_commit_message.outputs.message }} | |
| Original commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }}" || exit 0 | |
| git push | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: version-file-and-lint | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: "lts/*" | |
| - name: Install minification tools | |
| run: | | |
| npm install -g terser uglify-js clean-css-cli html-minifier | |
| - name: Minify JavaScript files | |
| run: | | |
| find . -type f -name "*.js" -not -path "./node_modules/*" | while read file; do | |
| file_basename=$(basename "$file") | |
| file_dirname=$(dirname "$file") | |
| map_filename="$file_dirname/$file_basename.map" | |
| terser "$file" --compress --mangle --source-map "base='.',root='/original-sources',url='$file_basename.map',filename='$map_filename',includeSources=true" -o "$file" | |
| done | |
| - name: Minify CSS files | |
| run: | | |
| find . -type f -name "*.css" -not -path "./node_modules/*" | while read file; do | |
| cleancss -o "$file" --source-map --source-map-inline-sources "$file" | |
| done | |
| - name: Minify HTML files | |
| run: | | |
| find . -type f -name "*.html" -not -path "./node_modules/*" | while read file; do | |
| html-minifier --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true -o "$file.min" "$file" | |
| mv "$file.min" "$file" | |
| done | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: "." | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |