Skip to content

Commit

Permalink
Misc update
Browse files Browse the repository at this point in the history
  • Loading branch information
RustyTake-Off committed Sep 30, 2024
1 parent ec7508b commit 052b41a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/actions/templates/moveFiles/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}" \
Expand Down
27 changes: 13 additions & 14 deletions .github/scripts/move_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 ''
Expand Down
4 changes: 2 additions & 2 deletions winfiles/to_move.yaml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions wslfiles/to_move.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TARGET_BRANCH_NAME: 'wslfiles'
OTHER_DIRS_FILES: 'shared/.gitconfig'
TARGET_BRANCH_NAME: "wslfiles"
OTHER_DIRS_FILES: "shared/.gitconfig"

0 comments on commit 052b41a

Please sign in to comment.