Skip to content

Commit

Permalink
fix: synchronization base error
Browse files Browse the repository at this point in the history
Must rebase head ref before syncing.

Log: fix synchronization base error
  • Loading branch information
asterwyx committed Jan 2, 2024
1 parent 5550c7f commit 31b3369
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/synchronize-to-dtk6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
source_repo:
type: string
required: true
source_repo:
type: string
required: true
source_ref:
type: string
required: true
Expand All @@ -25,18 +28,22 @@ jobs:
sync-pull-request:
runs-on: ubuntu-latest
steps:
- name: Checkout source repository ${{ inputs.source_repo }}
- name: Checkout source repository ${{ inputs.source_repo }}
uses: actions/checkout@v3
with:
token: ${{ env.GH_TOKEN }}
token: ${{ env.GH_TOKEN }}
ref: ${{ inputs.source_ref }}
path: 'source'
repository: ${{ inputs.source_repo }}
repository: ${{ inputs.source_repo }}
fetch-depth: 0

- name: Checkout dest repository ${{ inputs.dest_repo }}
uses: actions/checkout@v3
with:
token: ${{ env.GH_TOKEN }}
token: ${{ env.GH_TOKEN }}
ref: 'master'
path: 'dest'
Expand All @@ -51,12 +58,31 @@ jobs:
set -x
cd ${{ github.workspace }}/dest
git checkout -B ${tbranch}
git checkout -B ${tbranch}
cd ${{ github.workspace }}/source
git remote add upstream ${{ github.event.repository.clone_url }}
git fetch --all
git rebase upstream/master
if [[ -f ${{ github.workspace }}/source/.syncexclude ]]; then
rsync -avzp --delete --exclude=.git --exclude=.github --exclude=.obs --exclude=debian --exclude=archlinux --exclude=rpm --exclude-from=.syncexclude ${{ github.workspace }}/source/ ${{ github.workspace }}/dest/
rsync -avzp --delete --exclude=.git --exclude=.github --exclude=.obs --exclude=debian --exclude=archlinux --exclude=rpm --exclude-from=.syncexclude ${{ github.workspace }}/source/ ${{ github.workspace }}/dest/
else
rsync -avzp --delete --exclude=.git --exclude=.github --exclude=.obs --exclude=debian --exclude=archlinux --exclude=rpm ${{ github.workspace }}/source/ ${{ github.workspace }}/dest/
rsync -avzp --delete --exclude=.git --exclude=.github --exclude=.obs --exclude=debian --exclude=archlinux --exclude=rpm ${{ github.workspace }}/source/ ${{ github.workspace }}/dest/
fi
cd ${{ github.workspace }}/dest
difference=$(git diff)
echo "tbranch=${tbranch}" >> $GITHUB_OUTPUT
if [[ ! -z ${difference} ]]; then
echo "has_diff=true" >> $GITHUB_OUTPUT
else
echo "has_diff=false" >> $GITHUB_OUTPUT
fi
- name: Commit changes to ${{ inputs.dest_repo }}
if: steps.rsync.outputs.has_diff
run: |
tbranch=${{ steps.rsync.outputs.tbranch }}
cd ${{ github.workspace }}/dest
difference=$(git diff)
echo "tbranch=${tbranch}" >> $GITHUB_OUTPUT
Expand All @@ -77,9 +103,12 @@ jobs:
-m "Synchronize source files from ${{ github.repository }}." \
-m "Source-pull-request: https://github.com/${{ github.repository }}/pull/${{ inputs.pull_number }}"
git push -u -f origin ${tbranch}
-m "Source-pull-request: https://github.com/${{ github.repository }}/pull/${{ inputs.pull_number }}"
git push -u -f origin ${tbranch}
cd ${{ github.workspace }}/dest
gh repo set-default ${{ inputs.dest_repo }}
result=$(gh pr list --base master --head ${tbranch} --state open)
if [[ -z $result ]]; then
gh pr create -B master -H ${tbranch} --fill
gh pr create -B master -H ${tbranch} --fill
fi

0 comments on commit 31b3369

Please sign in to comment.