Skip to content

Sync branch to template #3

Sync branch to template

Sync branch to template #3

Workflow file for this run

name: Sync branch to template
on:
workflow_dispatch:
schedule:
- cron: '14 0 1 * *'
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync branch to template
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch_name=$(git rev-parse --abbrev-ref HEAD)
original_remote=$(git remote get-url origin)
pr_branch="sync-template/${branch_name}"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout -b "$pr_branch"
git clone https://github.com/ubiquity/ts-template
cp -rf ts-template/* .
rm -rf ts-template/
git add .
git commit -m "Sync template"
git push "$original_remote" "$pr_branch"
gh pr create --title "Sync branch to template" --body "This pull request merges changes from the template repository." --head "$pr_branch" --base "$branch_name"