Sync Fork Automatically #1
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: 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: Sync Fork | |
run: | | |
git remote add upstream $UPSTREAM_URL || true | |
git fetch upstream | |
git checkout main | |
git merge upstream/main --allow-unrelated-histories | |
git push origin main |