Skip to content

Commit 4021936

Browse files
author
zyrafal
committed
Add sync-template.yml workflow
1 parent 1ae7280 commit 4021936

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/sync-template.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Sync branch to template
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '14 0 1 * *'
7+
8+
jobs:
9+
sync:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get GitHub App token
21+
uses: tibdex/[email protected]
22+
id: get_installation_token
23+
with:
24+
app_id: ${{ secrets.APP_ID }}
25+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
26+
27+
- name: Sync branch to template
28+
env:
29+
GH_TOKEN: ${{ steps.get_installation_token.outputs.token }}
30+
IGNORE_FILES: "README.md another-file.txt"
31+
run: |
32+
branch_name=$(git rev-parse --abbrev-ref HEAD)
33+
original_remote=$(git remote get-url origin)
34+
pr_branch="sync-template/${branch_name}"
35+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
36+
git config --global user.name "github-actions[bot]"
37+
git checkout -b "$pr_branch"
38+
git clone https://github.com/ubiquity/ts-template
39+
for file in $IGNORE_FILES; do
40+
rm -rf "ts-template/$file"
41+
done
42+
cp -rf ts-template/* .
43+
rm -rf ts-template/
44+
git add .
45+
git commit -m "chore: sync template"
46+
git push "$original_remote" "$pr_branch"
47+
gh pr create --title "Sync branch to template" --body "This pull request merges changes from the template repository." --head "$pr_branch" --base "$branch_name"
48+
49+

0 commit comments

Comments
 (0)