Skip to content

Commit

Permalink
Merge pull request #108 from zyrafal/development
Browse files Browse the repository at this point in the history
Add sync-template.yml workflow that synchronizes the repo with ubiquity/ts-template every month
  • Loading branch information
0x4007 authored Sep 10, 2024
2 parents ab82b31 + 7bcdef9 commit 975fec5
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/sync-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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: Get GitHub App token
uses: tibdex/[email protected]
id: get_installation_token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Sync branch to template
env:
GH_TOKEN: ${{ steps.get_installation_token.outputs.token }}
IGNORE_FILES: "README.md another-file.txt"
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
for file in $IGNORE_FILES; do
rm -rf "ts-template/$file"
done
cp -rf ts-template/* .
rm -rf ts-template/
git add .
git commit -m "chore: 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"

0 comments on commit 975fec5

Please sign in to comment.