Skip to content
Merged
Changes from all 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
20 changes: 12 additions & 8 deletions .github/workflows/reusable-merge-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,19 @@ jobs:
- name: Set Default Push Branch
id: set-push-branch
env:
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "push-branch=${{ inputs.push-branch || github.event.repository.default_branch }}" >> "$GITHUB_OUTPUT"
push_branch=${{ inputs.push-branch }}
if [ -z "$push_branch" ]; then
push_branch=$(gh api /repos/${{ github.repository }} --jq '.push_branch')
fi
echo "push-branch=$push_branch" >> "$GITHUB_OUTPUT"

- name: Normalize Branch Names
id: normalize-branches
run: |
normalize_branch() {
echo "$1" | sed 's|^refs/heads/||'
echo "${1#refs/heads/}"
}
target_branch_normalized=$(normalize_branch "${{ inputs.target-branch }}")
push_branch_normalized=$(normalize_branch "${{ steps.set-push-branch.outputs.push-branch }}")
Expand Down Expand Up @@ -115,8 +119,8 @@ jobs:
git fetch origin
merge_log=$(git merge --no-commit --no-ff origin/${{ steps.normalize-branches.outputs.target-branch }} 2>&1)

log_length=$(echo "$merge_log" | wc -c)
log_length=${#merge_log}

if [ "$log_length" -ge 100 ]; then
echo "$merge_log" > dry-run-log.txt
echo "log-exists=1" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -144,7 +148,7 @@ jobs:
merge_target="origin/${{ steps.normalize-branches.outputs.target-branch }}"
current_branch=$(git rev-parse --abbrev-ref HEAD)

if git log ${current_branch}..${merge_target} --oneline | grep -q .; then
if git log "${current_branch}".."${merge_target}" --oneline | grep -q .; then
echo "Changes detected. Proceeding with merge..."

if [ "${{ inputs.fast-forward }}" == "true" ]; then
Expand Down Expand Up @@ -187,8 +191,8 @@ jobs:
- name: Get Current Commit SHA
id: set-sha
run: |
if ([ -n "${{ inputs.commit-id }}" ] && [ "${{ steps.branches-match.outputs.identical }}" == "1" ]) \
|| ([ -n "${{ inputs.commit-id }}" ] && [ "${{ steps.check-update.outputs.changed }}" != "1" ]); then
if { [ -n "${{ inputs.commit-id }}" ] && [ "${{ steps.branches-match.outputs.identical }}" == "1" ]; } \
|| { [ -n "${{ inputs.commit-id }}" ] && [ "${{ steps.check-update.outputs.changed }}" != "1" ]; }; then
echo "sha=${{ inputs.commit-id }}" >> "$GITHUB_OUTPUT"
else
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
Expand Down
Loading