Compare commits
3 Commits
c827757fb8
...
297f96ab99
Author | SHA1 | Date | |
---|---|---|---|
297f96ab99 | |||
3112316e7d | |||
1ca991e4b9 |
@ -29,6 +29,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
./zola build
|
./zola build
|
||||||
|
|
||||||
|
- name: Run postbuild script
|
||||||
|
run: bash ./postbuild.sh
|
||||||
|
|
||||||
- name: Set Destination Folder if MASTER
|
- name: Set Destination Folder if MASTER
|
||||||
if: ${{ github.ref == 'refs/heads/master' }}
|
if: ${{ github.ref == 'refs/heads/master' }}
|
||||||
run: echo "DEST_FOLDER=/srv/www/cz/filiprojek/www" >> $GITHUB_ENV
|
run: echo "DEST_FOLDER=/srv/www/cz/filiprojek/www" >> $GITHUB_ENV
|
||||||
|
36
postbuild.sh
Executable file
36
postbuild.sh
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
public_dir="./public"
|
||||||
|
css_extension=".css"
|
||||||
|
timestamp=$(date +%s)
|
||||||
|
|
||||||
|
# Define an array of folders to skip
|
||||||
|
skip_folders=("img" "svg" "fonts")
|
||||||
|
|
||||||
|
# Function to add timestamp to CSS files and update HTML imports
|
||||||
|
update_css_references() {
|
||||||
|
# Find all CSS files in the root of the public directory
|
||||||
|
for css_file in "$public_dir"/*$css_extension; do
|
||||||
|
if [[ -f "$css_file" ]]; then
|
||||||
|
base_name=$(basename "$css_file" "$css_extension")
|
||||||
|
new_name="${base_name}-${timestamp}${css_extension}"
|
||||||
|
|
||||||
|
# Rename the CSS file
|
||||||
|
mv "$css_file" "$public_dir/$new_name"
|
||||||
|
echo "Renamed: $css_file -> $new_name"
|
||||||
|
|
||||||
|
# Update all HTML files in the root and 'archiv' folder
|
||||||
|
for html_file in "$public_dir"/*.html "$public_dir/archiv/"*.html; do
|
||||||
|
if [[ -f "$html_file" ]]; then
|
||||||
|
sed -i "s|$base_name$css_extension|$new_name|g" "$html_file"
|
||||||
|
echo "Updated references in: $html_file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add timestamp to CSS files and update HTML references (including archiv/index.html)
|
||||||
|
update_css_references
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user