forked from upstream-mirrors/OpenTracks
ci: add scheduled workflow to auto-sync upstream changes
This commit is contained in:
@@ -0,0 +1,55 @@
|
|||||||
|
name: Auto-Sync Upstream
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 3 * * *' # Uruchamia się codziennie o 3:00 w nocy
|
||||||
|
workflow_dispatch: # Pozwala uruchomić to ręcznie z poziomu Gitea
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
name: Sync with Upstream
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: main
|
||||||
|
|
||||||
|
- name: Configure Git & Fetch
|
||||||
|
run: |
|
||||||
|
git config user.name "Gitea Actions Bot"
|
||||||
|
git config user.email "actions@gitea.local"
|
||||||
|
git remote add upstream https://gitea.local.labus.uk/upstream-mirrors/OpenTracks.git
|
||||||
|
git fetch upstream main
|
||||||
|
|
||||||
|
- name: Check for updates & Attempt Merge
|
||||||
|
id: merge
|
||||||
|
run: |
|
||||||
|
# Sprawdzamy czy są jakiekolwiek nowe zmiany
|
||||||
|
if git diff --quiet HEAD upstream/main; then
|
||||||
|
echo "Repozytorium jest aktualne. Brak zmian."
|
||||||
|
echo "has_changes=false" >> $GITHUB_ENV
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Znaleziono nowe zmiany. Próbuję scalić..."
|
||||||
|
echo "has_changes=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Próba automatycznego scalenia (merge)
|
||||||
|
if git merge upstream/main --no-edit; then
|
||||||
|
echo "Scalenie przebiegło pomyślnie!"
|
||||||
|
else
|
||||||
|
echo "Wykryto konflikty! Przerywam scalanie."
|
||||||
|
git merge --abort
|
||||||
|
exit 1 # Błąd celowy - Gitea wyśle Ci powiadomienie o failu
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Push changes
|
||||||
|
if: env.has_changes == 'true'
|
||||||
|
run: |
|
||||||
|
git push origin main
|
||||||
|
echo "Zmiany pomyślnie wypchnięte do repozytorium!"
|
||||||
Reference in New Issue
Block a user