Skip to content

Conversation

@cjlpowers
Copy link

@cjlpowers cjlpowers commented Aug 1, 2025

Description

Close #621

See #621 (comment)

  • Adds support for syncing from a non-default SOURCE_BRANCH.
  • Skips the commit step if git pull already created a merge commit.
  • Keeps the rest of the logic unchanged and close to the original.

Remark

For automation please see closing-issues-using-keywords

@AndreasAugustin
Copy link
Owner

@all-contributors please add @cjlpowers for code

@allcontributors
Copy link
Contributor

@AndreasAugustin

I've put up a pull request to add @cjlpowers! 🎉

@AndreasAugustin AndreasAugustin changed the title Add support for SOURCE_BRANCH feat: add support for SOURCE_BRANCH Nov 4, 2025
@AndreasAugustin AndreasAugustin self-assigned this Nov 4, 2025
@AndreasAugustin AndreasAugustin added bug Something isn't working enhancement New feature or request labels Nov 4, 2025
echo "::group::commit changes"

# Only commit if merge commit was not already created by git pull
if git log -1 --pretty=%B | grep -q "Merge"; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cjlpowers sorry for my late comment.
Actually I see a small issue with this part. If I understand right it requires that Merge is part of the commit message.
Actually it is not always the case for merge commits.

Possibly there is a better way to find out if it is a merge commit.

TEMPLATE_REMOTE_GIT_HASH=$(git ls-remote "${SOURCE_REPO}" HEAD | awk '{print $1}')
# Detect default branch of source repo if SOURCE_BRANCH is not set
if [[ -z "${SOURCE_BRANCH}" ]]; then
SOURCE_BRANCH=$(git ls-remote --symref "${SOURCE_REPO}" HEAD 2>/dev/null | awk -F'/' '/^ref:/ {print $NF}' | tr -d '\r\n')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately the tests are failing with message:

::info::prechecks passed
::info::Missing env variable 'UPSTREAM_BRANCH' setting to remote default main
::info::Detected default branch of source repo: main	HEAD
fatal: Needed a single revision
Error: Process completed with exit code 128.

https://github.com/AndreasAugustin/actions-template-sync/actions/runs/19081639124/job/54513049536

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Add possibity to change the branch of the source repo

2 participants