Skip to content

Commit 0b554ae

Browse files
Refactor file copying logic in deploy.yml
1 parent e4b9270 commit 0b554ae

1 file changed

Lines changed: 6 additions & 25 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,44 @@ on:
55
branches:
66
- main # Trigger the workflow on pushes to the main branch
77

8-
permissions:
9-
contents: write # Ensure the workflow can write to the repository
10-
118
jobs:
129
build:
1310
runs-on: ubuntu-latest
1411

1512
steps:
16-
# Step 1: Checkout the repository
1713
- name: Checkout Repository
1814
uses: actions/checkout@v3
1915

20-
# Step 2: Set up Node.js for minification and obfuscation tools
2116
- name: Set Up Node.js
2217
uses: actions/setup-node@v3
2318
with:
2419
node-version: '16'
2520

26-
# Step 3: Install minification and obfuscation tools
2721
- name: Install Minification and Obfuscation Tools
2822
run: |
2923
npm install -g terser clean-css-cli html-minifier-terser javascript-obfuscator
3024
31-
# Step 4: Minify and obfuscate JavaScript files
3225
- name: Minify and Obfuscate JavaScript
3326
run: |
34-
for file in $(find . -type f -name "*.js" ! -path "./node_modules/*" ! -path "./.vscode/*" ! -path "./.idea/*" ! -path "./bootstrap/*"); do
27+
for file in $(find ./assets/js -type f -name "*.js"); do
3528
javascript-obfuscator "$file" --output "$file"
3629
done
3730
38-
# Step 5: Minify CSS files
3931
- name: Minify CSS
4032
run: |
41-
for file in $(find . -type f -name "*.css" ! -path "./node_modules/*" ! -path "./.vscode/*" ! -path "./.idea/*" ! -path "./bootstrap/*"); do
33+
for file in $(find ./assets/css -type f -name "*.css"); do
4234
cleancss -o "$file" "$file"
4335
done
4436
45-
# Step 6: Minify HTML files
4637
- name: Minify HTML
4738
run: |
48-
for file in $(find . -type f -name "*.html" ! -path "./node_modules/*" ! -path "./.vscode/*" ! -path "./.idea/*" ! -path "./bootstrap/*"); do
39+
for file in $(find . -type f -name "*.html"); do
4940
html-minifier-terser --collapse-whitespace --remove-comments --minify-css true --minify-js true -o "$file" "$file"
5041
done
5142
52-
# Step 7: Copy non-minifiable files (images, videos) directly
53-
- name: Copy Non-Minifiable Files
54-
run: |
55-
for file in $(find . -type f ! -name "*.html" ! -name "*.css" ! -name "*.js" ! -path "./node_modules/*" ! -path "./.vscode/*" ! -path "./.idea/*" ! -path "./bootstrap/*"); do
56-
dest_dir="$(dirname "./minified/$file")"
57-
mkdir -p "$dest_dir"
58-
cp "$file" "$dest_dir/"
59-
done
60-
61-
# Step 8: Deploy to GitHub Pages
6243
- name: Deploy to GitHub Pages
6344
uses: JamesIves/github-pages-deploy-action@v4
6445
with:
65-
branch: gh-pages # Deploy to the gh-pages branch
66-
folder: . # Deploy everything from the root directory
67-
clean: true # Clean the gh-pages branch before deploying
46+
branch: gh-pages
47+
folder: . # Deploy files from the root of the repository
48+
clean: true # Ensures the gh-pages branch is cleaned before deploying

0 commit comments

Comments
 (0)