From 31935d560b8abe3081fa60f7e1a6cf929373407a Mon Sep 17 00:00:00 2001 From: Pavel Sukhodolski Date: Tue, 2 May 2023 23:53:21 +0400 Subject: [PATCH 1/2] excluded directories and fixes on copy all repo --- action.yml | 4 ++++ entrypoint.sh | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 30d8e28..a80c485 100644 --- a/action.yml +++ b/action.yml @@ -54,6 +54,9 @@ inputs: [Optional] create target branch if not exist. Defaults to `false` default: false required: false + exclude-directories: + description: '[Optional] The directory to exclude for remove from remote repo' + required: false runs: using: docker @@ -71,6 +74,7 @@ runs: - '${{ inputs.commit-message }}' - '${{ inputs.target-directory }}' - '${{ inputs.create-target-branch-if-needed }}' + - '${{ inputs.exclude-directories }}' branding: icon: git-commit color: green diff --git a/entrypoint.sh b/entrypoint.sh index 82048df..acc926b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,6 +16,7 @@ TARGET_BRANCH="${9}" COMMIT_MESSAGE="${10}" TARGET_DIRECTORY="${11}" CREATE_TARGET_BRANCH_IF_NEEDED="${12}" +EXCLUDE_DIRECTORIES="${13}" if [ -z "$DESTINATION_REPOSITORY_USERNAME" ] then @@ -115,7 +116,7 @@ mv "$TEMP_DIR/.git" "$CLONE_DIR/.git" echo "[+] List contents of $SOURCE_DIRECTORY" ls "$SOURCE_DIRECTORY" - +rm -rf "$SOURCE_DIRECTORY/.git" echo "[+] Checking if local $SOURCE_DIRECTORY exist" if [ ! -d "$SOURCE_DIRECTORY" ] then @@ -136,6 +137,7 @@ cp -ra "$SOURCE_DIRECTORY"/. "$CLONE_DIR/$TARGET_DIRECTORY" cd "$CLONE_DIR" echo "[+] Files that will be pushed" +chown -R $(id -u):$(id -g) . ls -la ORIGIN_COMMIT="https://$GITHUB_SERVER/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" @@ -155,7 +157,12 @@ fi echo "[+] Adding git commit" git add . - +if [ -n "$EXCLUDE_DIRECTORIES" ] +then + echo "[+] Checkout excluded dirs" + git reset -- "$EXCLUDE_DIRECTORIES" + git restore "$EXCLUDE_DIRECTORIES" +fi echo "[+] git status:" git status From 785fccdc08b61744fc7c4b944b966caaf42bc9ab Mon Sep 17 00:00:00 2001 From: Pavel Sukhodolski Date: Wed, 3 May 2023 00:16:39 +0400 Subject: [PATCH 2/2] change passing excluded directories to reset --- action.yml | 1 + entrypoint.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index a80c485..a71e162 100644 --- a/action.yml +++ b/action.yml @@ -56,6 +56,7 @@ inputs: required: false exclude-directories: description: '[Optional] The directory to exclude for remove from remote repo' + default: '' required: false runs: diff --git a/entrypoint.sh b/entrypoint.sh index acc926b..3dd759a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -160,8 +160,8 @@ git add . if [ -n "$EXCLUDE_DIRECTORIES" ] then echo "[+] Checkout excluded dirs" - git reset -- "$EXCLUDE_DIRECTORIES" - git restore "$EXCLUDE_DIRECTORIES" + git reset -- $(echo $EXCLUDE_DIRECTORIES) + git restore $(echo $EXCLUDE_DIRECTORIES) fi echo "[+] git status:" git status