|
| 1 | +name: Merge upstream/main into local main |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: '0 3 * * *' # täglich um 03:00 UTC |
| 5 | + workflow_dispatch: |
| 6 | +jobs: |
| 7 | + merge-upstream: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - name: Checkout |
| 11 | + uses: actions/checkout@v4 |
| 12 | + with: |
| 13 | + fetch-depth: 0 # wichtig, damit git alle Commits kennt |
| 14 | + - name: Set up Git |
| 15 | + run: | |
| 16 | + git config user.name "github-actions" |
| 17 | + git config user.email "github-actions@github.com" |
| 18 | + - name: Add upstream remote |
| 19 | + run: | |
| 20 | + git remote add upstream https://github.com/arduino/arduino-ide.git |
| 21 | + git fetch upstream |
| 22 | + - name: Check for relevant changes (skip merge if only .github/ etc.) |
| 23 | + id: check |
| 24 | + run: | |
| 25 | + git checkout main |
| 26 | + git fetch upstream |
| 27 | + #ROOT_FILES=$(grep -Ev '^\.github/|^\.git/|^[^/]+$') |
| 28 | + DIFF_FILES=$(git diff --name-only upstream/main HEAD | grep -Ev '^(\.github/|\.git/|^[^/]+$)' || true) |
| 29 | + echo "DIFF_FILES: $DIFF_FILES" |
| 30 | + if [ -z "$DIFF_FILES" ]; then |
| 31 | + echo "no_relevant_changes=true" >> $GITHUB_OUTPUT |
| 32 | + else |
| 33 | + echo "no_relevant_changes=false" >> $GITHUB_OUTPUT |
| 34 | + fi |
| 35 | + - name: Exit if no relevant changes |
| 36 | + if: steps.check.outputs.no_relevant_changes == 'true' |
| 37 | + run: | |
| 38 | + echo "❎ Only ignored files changed. Exiting." |
| 39 | + exit 0 |
| 40 | + - name: Merge upstream/main into local main |
| 41 | + run: | |
| 42 | + git merge upstream/main --no-edit |
| 43 | + continue-on-error: true # erlaubt Fehler z. B. bei Konflikten |
| 44 | + - name: Check for merge conflicts |
| 45 | + run: | |
| 46 | + if git ls-files -u | grep .; then |
| 47 | + echo "❌ Merge conflicts detected!" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + echo "✅ No merge conflicts" |
| 51 | + - name: Install GitHub CLI |
| 52 | + run: sudo apt-get install gh -y |
| 53 | + - name: Commit and push merge (optional PR instead) |
| 54 | + if: ${{ success() }} |
| 55 | + env: |
| 56 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + run: | |
| 58 | + # 🟢 Option 1: Direkt pushen (Standard) |
| 59 | + #git push origin main |
| 60 | +
|
| 61 | + # 🟡 Option 2: PR statt direktem Merge (kommentieren, falls gewünscht) |
| 62 | + BRANCH="upstream-merge-$(date +%s)" |
| 63 | + git checkout -b $BRANCH |
| 64 | + git push origin $BRANCH |
| 65 | + gh pr create --title "Merge from upstream" --body "Automatisch erstellter PR" --base main --head $BRANCH |
| 66 | + |
| 67 | + - name: Trigger BuildLinux workflow |
| 68 | + if: false && ${{ success() }} |
| 69 | + uses: benc-uk/workflow-dispatch@v1 |
| 70 | + with: |
| 71 | + workflow: BuildLinux.yml |
| 72 | + ref: main |
| 73 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
0 commit comments