⚒️ Config Sync #605
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: ⚒️ Config Sync | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '* * * * *' | |
workflow_dispatch: | |
jobs: | |
sync_files: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Checkout Config-Repository | |
uses: actions/checkout@v4 | |
with: | |
repository: "${{ github.repository_owner }}/.github" | |
path: upstream | |
- name: Sync .github directory | |
run: | | |
rsync -avz upstream/sync/ .github/ | |
rm -rf upstream | |
- name: Check for changes | |
id: changes | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "has_changes=true" >> $GITHUB_OUTPUT | |
else | |
echo "has_changes=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit changes | |
if: steps.changes.outputs.has_changes == 'true' | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git switch -c sync-config | |
git add -A | |
git commit -m "Sync from config repository" | |
git push origin HEAD | |
- name: Create Pull Request | |
if: steps.changes.outputs.has_changes == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr create \ | |
--title "Sync from config repository" \ | |
--body "This PR was automatically created to sync the .github directory." \ | |
--base main \ | |
--head sync-config |