Skip to content

Commit

Permalink
sync .gitattributes
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Nov 11, 2024
1 parent f3ea25b commit 53acf0e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/sync-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ jobs:
pr:
name: Submit PR
runs-on: ubuntu-latest
env:
target_branch: current
steps:
- uses: actions/checkout@v4
with:
ref: current
ref: ${{ env.target_branch }}
fetch-depth: 0
- name: Create PR
run: |
Expand All @@ -29,15 +31,23 @@ jobs:
git branch ${BRANCH_NAME} -f
git checkout ${BRANCH_NAME}
git config --global merge.ours.driver true
# sync .gitattributes first
git checkout origin/${{ github.ref_name }} -- .gitattributes
git add .gitattributes
if git diff-index --quiet HEAD --; then
echo "No changes to commit."
else
git commit -m "Sync .gitattributes from ${{ github.ref_name }}"
fi
git merge origin/${{ github.ref_name }}
git push origin ${BRANCH_NAME} --force
PR_URL="$(gh pr list --head "${BRANCH_NAME}" --state open --json url --jq .[].url)"
if [[ -n "${PR_URL}" ]]; then
echo "PR already exists -> ${PR_URL}"
exit 0
else
gh pr create --title "Sync master to current" --body "Generated by GitHub Actions" --base current -r njzjz -a njzjz
gh pr create --title "Sync ${{ github.ref_name }} to ${{ env.target_branch }}" --body "Generated by GitHub Actions" --base ${{ env.target_branch }} -r njzjz -a njzjz
fi
env:
GH_TOKEN: ${{ github.token }}
BRANCH_NAME: sync-master-to-current
BRANCH_NAME: sync-branches/${{ github.ref_name }}-to-${{ env.target_branch }}

0 comments on commit 53acf0e

Please sign in to comment.