Skip to content

Commit

Permalink
feat(#567): Add the name of the .templatesyncignore file as a paramet…
Browse files Browse the repository at this point in the history
…er (#568)


---------

Signed-off-by: Jonathan Østrup <[email protected]>
Co-authored-by: andy Augustin <[email protected]>
  • Loading branch information
TechnicallyJoe and AndreasAugustin authored Oct 15, 2024
1 parent 2e7777b commit 03661a8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -354,4 +354,4 @@
"skipCi": true,
"commitConvention": "angular",
"commitType": "docs"
}
}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -746,7 +752,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/brian6932"><img src="https://avatars.githubusercontent.com/u/18603393?v=4?s=100" width="100px;" alt="Brian"/><br /><sub><b>Brian</b></sub></a><br /><a href="https://github.com/AndreasAugustin/actions-template-sync/commits?author=brian6932" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MuriloChianfa"><img src="https://avatars.githubusercontent.com/u/60560085?v=4?s=100" width="100px;" alt="MuriloChianfa"/><br /><sub><b>MuriloChianfa</b></sub></a><br /><a href="https://github.com/AndreasAugustin/actions-template-sync/commits?author=MuriloChianfa" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/davidsnyder"><img src="https://avatars.githubusercontent.com/u/229108?v=4?s=100" width="100px;" alt="David Snyder"/><br /><sub><b>David Snyder</b></sub></a><br /><a href="#research-davidsnyder" title="Research">🔬</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://technicallyjoe.net/"><img src="https://avatars.githubusercontent.com/u/7877957?v=4?s=100" width="100px;" alt="Jonathan Østrup"/><br /><sub><b>Jonathan Østrup</b></sub></a><br /><a href="#ideas-TechnicallyJoe" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/AndreasAugustin/actions-template-sync/commits?author=TechnicallyJoe" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/technicallyjoe"><img src="https://avatars.githubusercontent.com/u/7877957?v=4?s=100" width="100px;" alt="Jonathan Østrup"/><br /><sub><b>Jonathan Østrup</b></sub></a><br /><a href="#ideas-TechnicallyJoe" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/AndreasAugustin/actions-template-sync/commits?author=TechnicallyJoe" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }}
9 changes: 7 additions & 2 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
########################################################
Expand All @@ -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}")

Expand Down Expand Up @@ -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

#####################################################
Expand Down

0 comments on commit 03661a8

Please sign in to comment.