Merge branch 'dev' into UMBE
This commit is contained in:
@@ -8,6 +8,8 @@ on:
|
||||
jobs:
|
||||
merge:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
reason: ${{ steps.check.outputs.reason }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -28,9 +30,15 @@ jobs:
|
||||
id: check
|
||||
run: |
|
||||
git fetch origin
|
||||
if [ $(git rev-list --count origin/staging..origin/main) -gt 0 ]; then
|
||||
COUNT=$(git rev-list --count origin/staging..origin/main)
|
||||
if [ "$COUNT" -gt 0 ]; then
|
||||
echo "reason=ok" >> $GITHUB_OUTPUT
|
||||
echo "❌ Staging is behind main and requires manual merging."
|
||||
exit 1
|
||||
elif [ "$COUNT" -eq 0 ]; then
|
||||
echo "reason=identical" >> $GITHUB_OUTPUT
|
||||
echo "✅ Staging and main are identical. Nothing to do."
|
||||
exit 42
|
||||
fi
|
||||
|
||||
- name: Create PR from staging to main
|
||||
@@ -53,7 +61,7 @@ jobs:
|
||||
|
||||
notify_failure:
|
||||
needs: merge
|
||||
if: failure()
|
||||
if: failure() && needs.merge.outputs.reason != 'identical'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Send Discord notification on failure
|
||||
@@ -61,16 +69,4 @@ 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 }}
|
||||
31
.github/workflows/prevent-wrong-pr.yml
vendored
Normal file
31
.github/workflows/prevent-wrong-pr.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: PR Rules Enforcement
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- staging
|
||||
|
||||
jobs:
|
||||
check-pr:
|
||||
runs-on: ubuntu-latest
|
||||
name: Validate Pull Request Sources
|
||||
steps:
|
||||
- name: Prevent dev merges
|
||||
run: |
|
||||
echo "${{ github.head_ref }}";
|
||||
echo "${{ github.base_ref }}";
|
||||
if [[ "${{ github.head_ref }}" == "dev" ]]; then
|
||||
echo "ERROR: Merging 'dev' into '${{ github.base_ref }}' is forbidden!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Allow only staging into main
|
||||
if: github.base_ref == 'main'
|
||||
run: |
|
||||
echo "${{ github.head_ref }}";
|
||||
echo "${{ github.base_ref }}";
|
||||
if [[ "${{ github.head_ref }}" != "staging" ]]; then
|
||||
echo "ERROR: Only 'staging' branch is allowed to merge into 'main'. Current: '${{ github.head_ref }}'"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user