Sync branch to template #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync branch to template | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '14 0 1 * *' | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Sync branch to template | |
run: | | |
branch_name=$(git rev-parse --abbrev-ref HEAD) | |
original_remote=$(git remote get-url origin) | |
pr_branch="sync/${branch_name}" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git remote add template https://github.com/ubiquity/ts-template | |
git fetch template development | |
git update-index --assume-unchanged ".github/workflows/sync.yml" | |
git merge template/development --allow-unrelated-histories || true | |
git checkout -b "$pr_branch" | |
git add . | |
git push "$original_remote" "$pr_branch" | |
- name: Create Pull Request | |
run: | | |
gh auth login | |
gh auth setup-git | |
gh pr create --title "Sync branch to template" --body "This pull request merges changes from the template repository." --head "$pr_branch" --base "$branch_name" | |