Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: config files inside .GitHub folder #252

Merged
merged 13 commits into from
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

It can also be stored inside `.github` folder.

## 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]"
Expand Down
19 changes: 13 additions & 6 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${NEW_TEMPLATE_GIT_HASH}"

echo "::group::Check new changes"
echo "::debug::new Git HASH ${NEW_TEMPLATE_GIT_HASH}"
if [ -r ${TEMPLATE_VERSION_FILE_NAME} ]
then

if [[ -f "$TEMPLATE_VERSION_FILE_NAME" ]]; then
LuisHenri marked this conversation as resolved.
Show resolved Hide resolved
echo "::debug::version file is located in root folder"
else
echo "::debug::version file is located either in .github folder or not present"
TEMPLATE_VERSION_FILE_NAME=".github/$TEMPLATE_VERSION_FILE_NAME"
LuisHenri marked this conversation as resolved.
Show resolved Hide resolved
fi
if [ -r ${TEMPLATE_VERSION_FILE_NAME} ]; then
CURRENT_TEMPLATE_GIT_HASH=$(cat ${TEMPLATE_VERSION_FILE_NAME})
echo "::debug::Current git hash ${CURRENT_TEMPLATE_GIT_HASH}"
fi

if [ "${NEW_TEMPLATE_GIT_HASH}" == "${CURRENT_TEMPLATE_GIT_HASH}" ]
then
if [ "${NEW_TEMPLATE_GIT_HASH}" == "${CURRENT_TEMPLATE_GIT_HASH}" ]; then
echo "::warn::repository is up to date"
exit 0
fi
Expand All @@ -65,10 +70,12 @@ echo "::endgroup::"
echo "::group::commit and push changes"
git add .

if [[ -f ".github/$TEMPLATE_SYNC_IGNORE_FILE_NAME" ]]; then
TEMPLATE_SYNC_IGNORE_FILE_NAME=".github/$TEMPLATE_SYNC_IGNORE_FILE_NAME"
LuisHenri marked this conversation as resolved.
Show resolved Hide resolved
fi
# we are checking the ignore file if it exists or is empty
# -s is true if the file contains whitespaces
if [ -s ${TEMPLATE_SYNC_IGNORE_FILE_NAME} ]
then
if [ -s ${TEMPLATE_SYNC_IGNORE_FILE_NAME} ]; then
echo "::debug::unstage files from template sync ignore"
git reset --pathspec-from-file="${TEMPLATE_SYNC_IGNORE_FILE_NAME}"

Expand Down