testign delpoy.yml #5
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: Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - main # Trigger the workflow on pushes to the main branch | |
| permissions: | |
| contents: write # Ensure the workflow can write to the repository | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| # Step 2: Set up Node.js for minification and obfuscation tools | |
| - name: Set Up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '16' | |
| # Step 3: Install minification and obfuscation tools | |
| - name: Install Minification and Obfuscation Tools | |
| run: | | |
| npm install -g terser clean-css-cli html-minifier-terser javascript-obfuscator | |
| # Step 4: Minify and obfuscate JavaScript files | |
| - name: Minify and Obfuscate JavaScript | |
| run: | | |
| for file in $(find . -type f -name "*.js" ! -path "./node_modules/*" ! -path "./.vscode/*" ! -path "./.idea/*" ! -path "./bootstrap/*"); do | |
| javascript-obfuscator "$file" --output "$file" | |
| done | |
| # Step 5: Minify CSS files | |
| - name: Minify CSS | |
| run: | | |
| for file in $(find . -type f -name "*.css" ! -path "./node_modules/*" ! -path "./.vscode/*" ! -path "./.idea/*" ! -path "./bootstrap/*"); do | |
| cleancss -o "$file" "$file" | |
| done | |
| # Step 6: Minify HTML files | |
| - name: Minify HTML | |
| run: | | |
| for file in $(find . -type f -name "*.html" ! -path "./node_modules/*" ! -path "./.vscode/*" ! -path "./.idea/*" ! -path "./bootstrap/*"); do | |
| html-minifier-terser --collapse-whitespace --remove-comments --minify-css true --minify-js true -o "$file" "$file" | |
| done | |
| # Step 7: Copy non-minifiable files (images, videos) directly | |
| - name: Copy Non-Minifiable Files | |
| run: | | |
| for file in $(find . -type f ! -name "*.html" ! -name "*.css" ! -name "*.js" ! -path "./node_modules/*" ! -path "./.vscode/*" ! -path "./.idea/*" ! -path "./bootstrap/*"); do | |
| mkdir -p "$(dirname $file)" | |
| rsync -a "$file" "$(dirname $file)/" | |
| done | |
| # Step 8: Deploy to GitHub Pages | |
| - name: Deploy to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: gh-pages # Deploy to the gh-pages branch | |
| folder: . # Deploy everything from the root directory | |
| clean: true # Clean the gh-pages branch before deploying |