Update
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
name: Auto Merge Staging into Main
|
name: Auto Merge Staging into Main
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 2 * * *' # 2:00 UTC = 4:00 Europäische Zeit
|
- cron: '0 2 * * *' # 2:00 UTC = 4:00 Europäische Zeit
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -12,17 +13,17 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set Git user
|
- name: Set Git user
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
- name: Fetch all branches
|
- name: Fetch all branches
|
||||||
run: |
|
run: |
|
||||||
git fetch origin main
|
git fetch origin main
|
||||||
git fetch origin staging
|
git fetch origin staging
|
||||||
|
|
||||||
- name: Check if main has commits not in staging
|
- name: Check if main has commits not in staging
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
@@ -31,21 +32,28 @@ jobs:
|
|||||||
echo "❌ Staging is behind main and requires manual merging."
|
echo "❌ Staging is behind main and requires manual merging."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Checkout staging and create branch
|
||||||
|
id: create_branch
|
||||||
|
run: |
|
||||||
|
git checkout staging
|
||||||
|
git checkout -b auto-merge/staging-to-main
|
||||||
|
git push origin auto-merge/staging-to-main
|
||||||
|
|
||||||
- name: Create PR from staging → main
|
- name: Create PR from staging → main
|
||||||
id: create_pr
|
id: create_pr
|
||||||
uses: peter-evans/create-pull-request@v4
|
uses: peter-evans/create-pull-request@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
commit-message: "chore: auto-merge staging into main"
|
commit-message: "chore: auto-merge staging into main"
|
||||||
branch: staging
|
branch: auto-merge/staging-to-main
|
||||||
base: main
|
base: main
|
||||||
title: "Auto-merge staging into main"
|
title: "Auto-merge staging into main"
|
||||||
body: |
|
body: |
|
||||||
This PR was created automatically by GitHub Actions.
|
This PR was created automatically by GitHub Actions.
|
||||||
It merges the latest `staging` into `main`.
|
It merges the latest `staging` into `main`.
|
||||||
draft: false
|
draft: false
|
||||||
|
|
||||||
- name: Enable auto-merge on PR
|
- name: Enable auto-merge on PR
|
||||||
if: steps.create_pr.outputs.pull-request-number != ''
|
if: steps.create_pr.outputs.pull-request-number != ''
|
||||||
uses: peter-evans/enable-pull-request-automerge@v3
|
uses: peter-evans/enable-pull-request-automerge@v3
|
||||||
@@ -53,7 +61,8 @@ jobs:
|
|||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }}
|
pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }}
|
||||||
merge-method: merge
|
merge-method: merge
|
||||||
|
|
||||||
|
|
||||||
notify_failure:
|
notify_failure:
|
||||||
needs: merge
|
needs: merge
|
||||||
if: failure()
|
if: failure()
|
||||||
@@ -62,10 +71,10 @@ jobs:
|
|||||||
- name: Send Discord notification on failure
|
- name: Send Discord notification on failure
|
||||||
run: |
|
run: |
|
||||||
curl -H "Content-Type: application/json" \
|
curl -H "Content-Type: application/json" \
|
||||||
-X POST \
|
-X POST \
|
||||||
-d "{\"content\": \"🚨 Auto-Merge fehlgeschlagen! Bitte manuell prüfen: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
|
-d "{\"content\": \"🚨 Auto-Merge fehlgeschlagen! Bitte manuell prüfen: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
|
||||||
${{ secrets.DISCORD_WEBHOOK_URL }}
|
${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
|
|
||||||
notify_success:
|
notify_success:
|
||||||
needs: merge
|
needs: merge
|
||||||
if: success()
|
if: success()
|
||||||
@@ -74,6 +83,6 @@ jobs:
|
|||||||
- name: Send Discord notification on success
|
- name: Send Discord notification on success
|
||||||
run: |
|
run: |
|
||||||
curl -H "Content-Type: application/json" \
|
curl -H "Content-Type: application/json" \
|
||||||
-X POST \
|
-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.\"}" \
|
-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 }}
|
${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
Reference in New Issue
Block a user