-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from Dasharo/pre-commit-ci-update-config
pre-commit: autoupdate hooks
- Loading branch information
Showing
5 changed files
with
90 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,18 +11,18 @@ jobs: | |
deploy: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4.1.1 | ||
with: | ||
submodules: true # Fetch Hugo themes (true OR recursive) | ||
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | ||
|
||
- name: Hugo setup | ||
uses: peaceiris/[email protected] | ||
with: | ||
hugo-version: "0.105.0" | ||
hugo-version: "0.111.3" | ||
extended: true | ||
|
||
- uses: actions/cache@v2 | ||
- uses: actions/cache@v4.0.0 | ||
with: | ||
path: /tmp/hugo_cache | ||
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }} | ||
|
@@ -35,7 +35,7 @@ jobs: | |
run: hugo --minify | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
uses: peaceiris/actions-gh-pages@v3.9.3 | ||
if: github.ref == 'refs/heads/main' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
# Check for the required parameters | ||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 <user@remote-host> <local-src-dir>" | ||
exit 1 | ||
fi | ||
|
||
# Function to clean up background processes when the script exits | ||
cleanup() { | ||
echo "Cleaning up..." | ||
# Kill the inotifywait background process | ||
kill $INOTIFY_PID | ||
} | ||
|
||
# Set trap to call cleanup function when the script exits | ||
trap cleanup exit | ||
|
||
REMOTE_USER_HOST="$1" | ||
LOCAL_SRC_DIR="$2" # Local source directory provided as the second parameter | ||
REMOTE_SRC_DIR="/tmp/3mdeb-website" | ||
DOCKER_IMAGE="klakegg/hugo:0.111.3-ext-alpine" | ||
DOCKER_PORT="1313" | ||
REMOTE_HOST=$(echo $REMOTE_USER_HOST | cut -d '@' -f2) | ||
|
||
# Set DOCKER_HOST environment variable | ||
export DOCKER_HOST="tcp://$REMOTE_HOST:2375" | ||
|
||
# Function to continuously sync local directory with remote directory | ||
start_sync() { | ||
ssh $REMOTE_USER_HOST "rm -rf $REMOTE_SRC_DIR" | ||
rsync -avz --exclude='.git/' $LOCAL_SRC_DIR $REMOTE_USER_HOST:$REMOTE_SRC_DIR | ||
inotifywait -m -r -e modify,create,delete --exclude '^\.git/' --format '%w%f' $LOCAL_SRC_DIR | while read file; do | ||
# Check if the changed file is not inside .git directory | ||
if [[ $file != *".git"* ]]; then | ||
rsync -avz --exclude='.git/' $LOCAL_SRC_DIR $REMOTE_USER_HOST:$REMOTE_SRC_DIR | ||
fi | ||
done & | ||
INOTIFY_PID=$! | ||
} | ||
|
||
# Function to run Docker container on remote host | ||
run_docker_container() { | ||
docker run --rm -it -v $REMOTE_SRC_DIR:/src -p $DOCKER_PORT:$DOCKER_PORT -u $(id -u) $DOCKER_IMAGE serve -b $REMOTE_HOST | ||
} | ||
|
||
#!/bin/bash | ||
|
||
# Function to check if a command exists | ||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
# Check for required commands | ||
if ! command_exists rsync; then | ||
echo "rsync is not installed. Please install it." | ||
exit 1 | ||
fi | ||
|
||
if ! command_exists inotifywait; then | ||
echo "inotify-tools is not installed. Please install it." | ||
exit 1 | ||
fi | ||
|
||
# Start continuous synchronization in the background | ||
start_sync | ||
|
||
# Run Docker container | ||
run_docker_container | ||
|
||
# After the Docker container exits, kill the background sync process | ||
kill $! |
This file contains 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