Skip to content

Add sync.yml to repos #19

Add sync.yml to repos

Add sync.yml to repos #19

name: Add sync.yml to repos
on:
workflow_dispatch:
jobs:
update-repos:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Add sync.yml to each repo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
sync_path=$(realpath .github/workflows/sync.yml)
original_remote=$(git remote get-url origin)
repos=$(gh repo list ubiquity --limit 1 --json name,updatedAt -q '.[] | select(.updatedAt > (now - 30*24*60*60)) | .name')
for REPO in $repos; do
echo "Processing $REPO"
gh repo clone ubiquity/$REPO
cd $REPO
branch_name="add-sync-script"
git checkout -b $branch_name
mkdir -p .github/workflows
cp $sync_path .github/workflows/sync.yml
git add .github/workflows/sync.yml
git commit -m "Add sync.yml workflow"
git push "$original_remote" "$branch_name"
gh pr create --title "Add sync.yml workflow that synchronizes the template every month" --body "Details: https://github.com/ubiquity/ts-template/issues/54" --head "$original_remote:$branch_name" --base development
cd ..
rm -rf $REPO
done