Sync Fork Automatically #9
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: Sync Fork Automatically | |
on: | |
schedule: | |
- cron: '0 */12 * * *' # Každých 12 hodín | |
workflow_dispatch: # Umožní manuálne spustenie | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Fork | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Aby sme mali celý git log | |
- name: Configure Git Identity | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Get Original Repository URL | |
id: get_upstream | |
run: | | |
UPSTREAM_URL=$(jq -r '.parent.html_url' <<< $(curl -s "https://api.github.com/repos/${{ github.repository }}")) | |
echo "UPSTREAM_URL=$UPSTREAM_URL" >> $GITHUB_ENV | |
- name: Add Upstream Remote and Fetch | |
run: | | |
git remote add upstream $UPSTREAM_URL || true | |
git fetch upstream | |
- name: Sync Fork with Upstream | |
run: | | |
git checkout main | |
git merge upstream/main --no-edit || git merge --abort | |
git push origin main |