From 052b41abdc3036dac7ce1172a5f6c07167ff7af1 Mon Sep 17 00:00:00 2001 From: RustyTake-Off <109174317+RustyTake-Off@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:22:08 +0200 Subject: [PATCH] Misc update --- .../actions/templates/moveFiles/action.yaml | 2 ++ .github/scripts/move_files.sh | 27 +++++++++---------- winfiles/to_move.yaml | 4 +-- wslfiles/to_move.yaml | 4 +-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/actions/templates/moveFiles/action.yaml b/.github/actions/templates/moveFiles/action.yaml index 804b51a..43d222e 100644 --- a/.github/actions/templates/moveFiles/action.yaml +++ b/.github/actions/templates/moveFiles/action.yaml @@ -34,6 +34,7 @@ runs: run: | TARGET_BRANCH_NAME=$(yq '.TARGET_BRANCH_NAME' "${{ inputs.CONFIG_FILE_PATH }}") OTHER_DIRS_FILES=$(yq '.OTHER_DIRS_FILES' "${{ inputs.CONFIG_FILE_PATH }}") + echo "TARGET_BRANCH_NAME=${TARGET_BRANCH_NAME}" >> $GITHUB_ENV echo "OTHER_DIRS_FILES=${OTHER_DIRS_FILES}" >> $GITHUB_ENV @@ -42,6 +43,7 @@ runs: shell: bash run: | chmod +x .github/scripts/move_files.sh + .github/scripts/move_files.sh \ "${{ inputs.SOURCE_BRANCH_NAME }}" \ "${{ env.TARGET_BRANCH_NAME }}" \ diff --git a/.github/scripts/move_files.sh b/.github/scripts/move_files.sh index 0ef283d..27595c1 100644 --- a/.github/scripts/move_files.sh +++ b/.github/scripts/move_files.sh @@ -4,16 +4,15 @@ # GitHub - https://github.com/RustyTake-Off # GitHub Repo - https://github.com/RustyTake-Off/dotfiles # Author - RustyTake-Off -# Version - 0.1.3 set -e # Variables passed as inputs -declare SOURCE_BRANCH_NAME="$1" -declare TARGET_BRANCH_NAME="$2" -declare OTHER_DIRS_FILES="$3" -declare USER_NAME="$4" -declare USER_EMAIL="$5" +source_branch_name="$1" +target_branch_name="$2" +other_dirs_files="$3" +user_name="$4" +user_email="$5" # Stash changes in the .github directory to fix error, after changing move_files.sh script permissions git stash push -m "Stash .github changes" -- .github @@ -27,20 +26,20 @@ git reset > /dev/null # Checkout necessary files and directories git checkout "$SOURCE_BRANCH_NAME" -- $TARGET_BRANCH_NAME > /dev/null -[ -n "$OTHER_DIRS_FILES" ] \ +[[ -n "$OTHER_DIRS_FILES" ]] \ && git checkout "$SOURCE_BRANCH_NAME" -- $OTHER_DIRS_FILES > /dev/null # Copy files and directories cp -r "$TARGET_BRANCH_NAME"/* . find "$TARGET_BRANCH_NAME" -maxdepth 1 -name '.*[!.]*' -exec cp -r {} . \; -if [ -n "$OTHER_DIRS_FILES" ]; then +if [[ -n "$OTHER_DIRS_FILES" ]]; then shopt -s dotglob for item in $OTHER_DIRS_FILES; do - if [ -f "$item" ] && [ -s "$item" ]; then + if [[ -f "$item" ]] && [[ -s "$item" ]]; then cp "$item" . - elif [ -d "$item" ]; then + elif [[ -d "$item" ]]; then cp -r "$item" . fi done @@ -52,11 +51,11 @@ fi rm -rf "$TARGET_BRANCH_NAME" rm README.md to_move.yaml -if [ -n "$OTHER_DIRS_FILES" ]; then +if [[ -n "$OTHER_DIRS_FILES" ]]; then for item in $OTHER_DIRS_FILES; do - dir=$(dirname "$item") - [ -d "$dir" ] && rm -rf "$dir" + dir="${item%/*}" + [[ -d "$dir" ]] && rm -rf "$dir" done fi @@ -67,7 +66,7 @@ git config --global user.email "$USER_EMAIL" git add --all -if [ -z "$(git diff --staged)" ]; then +if [[ -z "$(git diff --staged)" ]]; then echo '' echo '=== No changes to commit ============' echo '' diff --git a/winfiles/to_move.yaml b/winfiles/to_move.yaml index 5b0775e..0445f73 100644 --- a/winfiles/to_move.yaml +++ b/winfiles/to_move.yaml @@ -1,2 +1,2 @@ -TARGET_BRANCH_NAME: 'winfiles' -OTHER_DIRS_FILES: 'genfiles/images shared/.gitconfig' +TARGET_BRANCH_NAME: "winfiles" +OTHER_DIRS_FILES: "genfiles/images shared/.gitconfig" diff --git a/wslfiles/to_move.yaml b/wslfiles/to_move.yaml index 22d6477..9d37040 100644 --- a/wslfiles/to_move.yaml +++ b/wslfiles/to_move.yaml @@ -1,2 +1,2 @@ -TARGET_BRANCH_NAME: 'wslfiles' -OTHER_DIRS_FILES: 'shared/.gitconfig' +TARGET_BRANCH_NAME: "wslfiles" +OTHER_DIRS_FILES: "shared/.gitconfig"