diff --git a/.all-contributorsrc b/.all-contributorsrc index 433411dc..b1883119 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -339,7 +339,7 @@ "login": "TechnicallyJoe", "name": "Jonathan Østrup", "avatar_url": "https://avatars.githubusercontent.com/u/7877957?v=4", - "profile": "https://technicallyjoe.net/", + "profile": "https://github.com/technicallyjoe", "contributions": [ "ideas", "code" @@ -354,4 +354,4 @@ "skipCi": true, "commitConvention": "angular", "commitType": "docs" -} +} \ No newline at end of file diff --git a/README.md b/README.md index b559de6b..a5f47abf 100644 --- a/README.md +++ b/README.md @@ -269,6 +269,7 @@ jobs: | gpg_private_key | `[optional]` set if you want to sign commits | `false` | | | gpg_passphrase | `[optional]` set if your optionial gpg private key has a passphrase | `false` | | | steps | `[optional] add the steps you want to execute within the action` | `false` | all steps will be executed | +| template_sync_ignore_file_path | `[optional] set the path to the ignore file.` | false |`.templatesyncignore` | | is_with_tags | `[optional]` set to `true` if tags should be synced | `false` | `false` | ### Action Outputs @@ -316,6 +317,11 @@ in defining the files and folders that should be excluded from syncing with the It can also be stored inside `.github` folder. +The `template_sync_ignore_file_path` parameter allows you to specify a path to an ignore file. This variable defaults to `.templatesyncignore`. +Changing this allows you to support template sync with more than one repository using different ignore files. + +The action will look for the path specified within `.` or `.github/` + _Note: It is not possible to sync also the `.templatesyncignore` itself. Any changes from the template repository will be restored automatically._ **Remark** reading the [gitglossary][git-glossary] (_pathspec_ section) you see a slight difference to the `.gitignore` file @@ -746,7 +752,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Brian
Brian

📖 MuriloChianfa
MuriloChianfa

📖 David Snyder
David Snyder

🔬 - Jonathan Østrup
Jonathan Østrup

🤔 💻 + Jonathan Østrup
Jonathan Østrup

🤔 💻 diff --git a/action.yml b/action.yml index 9ab9ef56..c7e04b08 100644 --- a/action.yml +++ b/action.yml @@ -72,6 +72,9 @@ inputs: description: "[optional] set if your private gpg key has a password" steps: description: "[optional] set the steps to execute within the action" + template_sync_ignore_file_path: + description: "[optional] set the path to the ignore file" + default: ".templatesyncignore" is_with_tags: description: "[optional] set to true if tags should be synced" default: "false" @@ -118,4 +121,5 @@ runs: GPG_PRIVATE_KEY: ${{ inputs.gpg_private_key }} GPG_PASSPHRASE: ${{ inputs.gpg_passphrase }} STEPS: ${{ inputs.steps }} + TEMPLATE_SYNC_IGNORE_FILE_PATH: ${{ inputs.template_sync_ignore_file_path }} IS_WITH_TAGS: ${{ inputs.is_with_tags }} diff --git a/src/sync_template.sh b/src/sync_template.sh index 585a4aee..b91d9c7a 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -28,6 +28,11 @@ if ! [ -x "$(command -v gh)" ]; then exit 1; fi +if [[ -z "${TEMPLATE_SYNC_IGNORE_FILE_PATH}" ]]; then + err "Missing env variable 'TEMPLATE_SYNC_IGNORE_FILE_PATH'"; + exit 1; +fi + ######################################################## # Variables ######################################################## @@ -42,12 +47,12 @@ if [[ -n "${SRC_SSH_PRIVATEKEY_ABS_PATH}" ]]; then export GIT_SSH_COMMAND="ssh -i ${SRC_SSH_PRIVATEKEY_ABS_PATH}" fi +TEMPLATE_SYNC_IGNORE_FILE_PATH="${TEMPLATE_SYNC_IGNORE_FILE_PATH:-".templatesyncignore"}" IS_WITH_TAGS="${IS_WITH_TAGS:-"false"}" IS_FORCE_PUSH_PR="${IS_FORCE_PUSH_PR:-"false"}" IS_KEEP_BRANCH_ON_PR_CLEANUP="${IS_KEEP_BRANCH_ON_PR_CLEANUP:-"false"}" GIT_REMOTE_PULL_PARAMS="${GIT_REMOTE_PULL_PARAMS:---allow-unrelated-histories --squash --strategy=recursive -X theirs}" -TEMPLATE_SYNC_IGNORE_FILE_PATH=".templatesyncignore" TEMPLATE_REMOTE_GIT_HASH=$(git ls-remote "${SOURCE_REPO}" HEAD | awk '{print $1}') SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") @@ -75,7 +80,7 @@ debug "PR_BODY ${PR_BODY}" # Check if the Ignore File exists inside .github folder or if it doesn't exist at all if [[ -f ".github/${TEMPLATE_SYNC_IGNORE_FILE_PATH}" || ! -f "${TEMPLATE_SYNC_IGNORE_FILE_PATH}" ]]; then debug "using ignore file as in .github folder" - TEMPLATE_SYNC_IGNORE_FILE_PATH=".github/${TEMPLATE_SYNC_IGNORE_FILE_PATH}" + TEMPLATE_SYNC_IGNORE_FILE_PATH=".github/${TEMPLATE_SYNC_IGNORE_FILE_PATH}" fi #####################################################