From dd6bb2c1ff98261bbd48933ba3b776b555801953 Mon Sep 17 00:00:00 2001 From: Marc Siebeneicher Date: Fri, 23 Dec 2022 20:08:19 +0100 Subject: [PATCH] fix(sync-template): fix issue with .templatesyncignore conflicts (#251) * fix(sync-template): fix issue with .templatesyncignore conflicts * fix(sync-template): fix issue with .templatesyncignore conflicts * docs(sync-template): update docs regarding .templatesyncignore conflicts * fix(sync-template): fix issue with .templatesyncignore by git * chore(sync-template): cleanup code --- README.md | 2 ++ src/sync_template.sh | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 3b05ac1..0e84063 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,8 @@ jobs: Create a `.templatesyncignore` file. Just like writing a `.gitignore` file, follow the [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) in defining the files and folders that should be excluded from syncing with the template repository. +_Note: It is not possible to sync also the `.templatesyncignore` itself. Any changes from the template repository will be restored automatically._ + ## Debug You must create a secret named `ACTIONS_STEP_DEBUG` with the value `true` to see the debug messages set by this command in the log. For more information, see "[Enabling debug logging.][enabling-debug-logging]" diff --git a/src/sync_template.sh b/src/sync_template.sh index a0a16b3..b750d23 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -56,6 +56,14 @@ echo "::debug::pull changes from template" git pull "${SOURCE_REPO}" --allow-unrelated-histories --squash --strategy=recursive -X theirs echo "::endgroup::" +if [ -s ${TEMPLATE_SYNC_IGNORE_FILE_NAME} ] +then + echo "::group::restore ignore file" + git reset ${TEMPLATE_SYNC_IGNORE_FILE_NAME} + git checkout -- ${TEMPLATE_SYNC_IGNORE_FILE_NAME} + echo "::endgroup::" +fi + echo "::group::persist template version" echo "write new template version file" echo "${NEW_TEMPLATE_GIT_HASH}" > ${TEMPLATE_VERSION_FILE_NAME}