Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Github Actions script that synchronizes the template every month. #56

Merged
merged 32 commits into from
Sep 8, 2024
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0e9b021
feat: add sync.yml which runs every month
zyrafal Aug 20, 2024
a9fde24
feat: create a pull request
zyrafal Aug 21, 2024
4c71cdf
feat: create add-sync-to-repos.yml
zyrafal Aug 21, 2024
5e80ccd
fix: some typos
zyrafal Aug 21, 2024
0a13430
fix: github token
zyrafal Aug 21, 2024
0a23113
fix: disable substitution
zyrafal Aug 21, 2024
7b80b79
fix: git auth
zyrafal Aug 21, 2024
ec92464
fix: uncomment push and pr
zyrafal Aug 21, 2024
547de5f
fix: use sed
zyrafal Aug 21, 2024
426e349
fix: move git config
zyrafal Aug 21, 2024
747d03d
fix: change pr title
zyrafal Aug 21, 2024
9b0e70b
fix: add original_remote variable
zyrafal Aug 21, 2024
3d04254
fix: add debug prints
zyrafal Aug 21, 2024
b006f48
fix: remove push
zyrafal Aug 21, 2024
f5e88a8
fix: typo
zyrafal Aug 21, 2024
42c69b6
fix: copy the file
zyrafal Aug 21, 2024
cf09a00
fix: typo
zyrafal Aug 21, 2024
a969b82
fix: typo
zyrafal Aug 21, 2024
626269f
fix: create a branch in this repository
zyrafal Aug 21, 2024
1d9a0dc
fix: typo
zyrafal Aug 21, 2024
7f261f9
fix: add git config url
zyrafal Aug 21, 2024
edf90e8
fix: try on this repo
zyrafal Aug 21, 2024
ab9d76d
fix: quotes
zyrafal Aug 21, 2024
3174b20
fix: replace repo
zyrafal Aug 21, 2024
63530cc
fix: try forking the repo
zyrafal Aug 21, 2024
fddee05
fix: add write permission to sync.yml
zyrafal Aug 21, 2024
de08e6f
fix: delete add-sync-to-repos.yml
zyrafal Aug 21, 2024
67f39ba
fix: add pull-requests permission to sync.yml
zyrafal Aug 21, 2024
89a8e54
fix: avoid merge conflicts and rename sync.yml to sync-template.yml
zyrafal Aug 30, 2024
b5235dc
Update sync-template.yml
0x4007 Sep 1, 2024
4356e5c
feat: add a list of ignored files
zyrafal Sep 4, 2024
89b942e
feat: auth as the bot
zyrafal Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"