Merge branch 'staging' into dev

This commit is contained in:
Moritz Utcke
2025-04-28 17:28:14 -03:00
3 changed files with 33 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ name: Auto Merge Staging into Main
on:
schedule:
- cron: '0 2 * * *' # 2:00 UTC = 4:00 CET
- cron: '0 2 * * *' # 2:00 UTC = 4:00 Europäische Zeit
workflow_dispatch:
jobs:
@@ -27,17 +27,29 @@ jobs:
- name: Check if main has commits not in staging
id: check
run: |
if ! git merge-base --is-ancestor origin/staging origin/main; then
echo "Main hat neuere Commits als Staging. Merge wird abgebrochen."
git fetch origin
if [ $(git rev-list --count origin/staging..origin/main) -gt 0 ]; then
echo "❌ Staging is behind main and requires manual merging."
exit 1
fi
- name: Merge staging into main
if: steps.check.outcome == 'success'
- name: Create PR from staging to main
id: create_pr
run: |
git checkout main
git merge origin/staging --no-ff --no-edit
git push origin main
PR_URL=$(gh pr create --base main --head staging --title "Auto-merge staging into main" --body "This PR was created automatically by GitHub Actions. It merges the latest \`staging\` into \`main\`.")
echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT
PR_NUMBER=$(echo $PR_URL | awk -F'/' '{print $NF}')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge on PR
if: steps.create_pr.outputs.PR_NUMBER != ''
run: |
gh pr merge ${{ steps.create_pr.outputs.PR_NUMBER }} --merge --auto
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify_failure:
needs: merge
@@ -49,4 +61,16 @@ jobs:
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"🚨 Auto-Merge fehlgeschlagen! Bitte manuell prüfen: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
${{ secrets.DISCORD_WEBHOOK_URL }}
notify_success:
needs: merge
if: success()
runs-on: ubuntu-latest
steps:
- name: Send Discord notification on success
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"✅ Auto-Merge ausgeführt! Ergebnis jetzt auf [GitHub](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) und [online-energieausweis.org](https://online-energieausweis.org) einsehen.\"}" \
${{ secrets.DISCORD_WEBHOOK_URL }}

View File

@@ -1,8 +1,6 @@
name: Development Pipeline
on:
pull_request:
branches: [dev]
push:
branches: [dev]

View File

@@ -9,7 +9,7 @@ on:
jobs:
check-pr:
runs-on: ubuntu-latest
name: Validate Pull Request Source
name: Validate Pull Request Sources
steps:
- name: Prevent dev merges
run: |