From 3f57d6e539d1f55fd810dc5c272bc8e0afb12f1b Mon Sep 17 00:00:00 2001 From: gqx Date: Fri, 19 Apr 2024 16:20:13 +0300 Subject: [PATCH 1/3] add option to keep gitattributes file --- action.yml | 7 +++++++ entrypoint.sh | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/action.yml b/action.yml index 30d8e28..8591f3a 100644 --- a/action.yml +++ b/action.yml @@ -54,6 +54,12 @@ inputs: [Optional] create target branch if not exist. Defaults to `false` default: false required: false + keep-gitattributes: + type: boolean + description: >- + [Optional] If true, .gitattributes will not be overwritten. Required for LFS in target repo. Defaults to `false` + default: false + required: false runs: using: docker @@ -71,6 +77,7 @@ runs: - '${{ inputs.commit-message }}' - '${{ inputs.target-directory }}' - '${{ inputs.create-target-branch-if-needed }}' + - '${{ inputs.keep-gitattributes }}' branding: icon: git-commit color: green diff --git a/entrypoint.sh b/entrypoint.sh index f5eb0da..4f2eafa 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}" +KEEP_GITATTRIBUTES="${13}" if [ -z "$DESTINATION_REPOSITORY_USERNAME" ] then @@ -100,6 +101,13 @@ TEMP_DIR=$(mktemp -d) # including "." and with the exception of ".git/" mv "$CLONE_DIR/.git" "$TEMP_DIR/.git" +# If enabled, copy .gitattributes file to keep LFS working. +if [ "$KEEP_GITATTRIBUTES" = "true" ] +then + mv "$CLONE_DIR/.gitattributes" "$TEMP_DIR/.gitattributes" +fi + + # $TARGET_DIRECTORY is '' by default ABSOLUTE_TARGET_DIRECTORY="$CLONE_DIR/$TARGET_DIRECTORY/" @@ -116,6 +124,11 @@ echo "[+] Listing root Location" ls -al / mv "$TEMP_DIR/.git" "$CLONE_DIR/.git" +# If enabled, restore .gitattributes file to keep LFS working. +if [ "$KEEP_GITATTRIBUTES" = "true" ] +then + mv "$TEMP_DIR/.gitattributes" "$CLONE_DIR/.gitattributes" +fi echo "[+] List contents of $SOURCE_DIRECTORY" ls "$SOURCE_DIRECTORY" From 8aec05af3066609ebbc02f386fccb4bd04fa5093 Mon Sep 17 00:00:00 2001 From: gqx Date: Fri, 19 Apr 2024 16:28:56 +0300 Subject: [PATCH 2/3] remove one check, add log --- entrypoint.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4f2eafa..977848b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -100,12 +100,7 @@ TEMP_DIR=$(mktemp -d) # but not anymore. Otherwise we had to remove the files from "$CLONE_DIR", # including "." and with the exception of ".git/" mv "$CLONE_DIR/.git" "$TEMP_DIR/.git" - -# If enabled, copy .gitattributes file to keep LFS working. -if [ "$KEEP_GITATTRIBUTES" = "true" ] -then - mv "$CLONE_DIR/.gitattributes" "$TEMP_DIR/.gitattributes" -fi +mv "$CLONE_DIR/.gitattributes" "$TEMP_DIR/.gitattributes" # $TARGET_DIRECTORY is '' by default @@ -127,6 +122,7 @@ mv "$TEMP_DIR/.git" "$CLONE_DIR/.git" # If enabled, restore .gitattributes file to keep LFS working. if [ "$KEEP_GITATTRIBUTES" = "true" ] then + echo "[+] Restoring .gitattributes file" mv "$TEMP_DIR/.gitattributes" "$CLONE_DIR/.gitattributes" fi From 082e18d3e1eccdcdfc775eae865fbf25bb8ad950 Mon Sep 17 00:00:00 2001 From: gqx Date: Sat, 1 Jun 2024 22:22:52 +0300 Subject: [PATCH 3/3] Temp fix for git-lfs issue 5749 --- entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 977848b..41017c9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,6 +18,9 @@ TARGET_DIRECTORY="${11}" CREATE_TARGET_BRANCH_IF_NEEDED="${12}" KEEP_GITATTRIBUTES="${13}" +## Temp fix for git-lfs issue 5749 +export GIT_CLONE_PROTECTION_ACTIVE=false + if [ -z "$DESTINATION_REPOSITORY_USERNAME" ] then DESTINATION_REPOSITORY_USERNAME="$DESTINATION_GITHUB_USERNAME"