From b29b26ef0e978a2ba01d81a1d7384bbf126189a3 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 12:58:54 -0300 Subject: [PATCH 01/19] Update --- .github/workflows/prevent-wrong-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prevent-wrong-pr.yml b/.github/workflows/prevent-wrong-pr.yml index c89c197b..c2073db3 100644 --- a/.github/workflows/prevent-wrong-pr.yml +++ b/.github/workflows/prevent-wrong-pr.yml @@ -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: | From 8c4345924ffcd6d535e73f9e74482c0d2d3b7777 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 13:10:16 -0300 Subject: [PATCH 02/19] Update dev pipeline --- .github/workflows/dev-pipeline.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/dev-pipeline.yml b/.github/workflows/dev-pipeline.yml index c0de330f..b67202a2 100644 --- a/.github/workflows/dev-pipeline.yml +++ b/.github/workflows/dev-pipeline.yml @@ -1,8 +1,6 @@ name: Development Pipeline on: - pull_request: - branches: [dev] push: branches: [dev] From 72049577497468f96c235e83ce08a82b619a2dfa Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 13:10:16 -0300 Subject: [PATCH 03/19] Update dev pipeline --- .github/workflows/dev-pipeline.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/dev-pipeline.yml b/.github/workflows/dev-pipeline.yml index c0de330f..b67202a2 100644 --- a/.github/workflows/dev-pipeline.yml +++ b/.github/workflows/dev-pipeline.yml @@ -1,8 +1,6 @@ name: Development Pipeline on: - pull_request: - branches: [dev] push: branches: [dev] From ec0d5ddf5a2526c53ef464cbeac54264f46c2496 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 13:23:33 -0300 Subject: [PATCH 04/19] Update workflow --- .github/workflows/auto-merge-staging-into-main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 42255d3c..4e9b15e6 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -49,4 +49,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 }} \ No newline at end of file From 058b61908f9057b42fc5c77de81db364eb48bcdd Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 13:31:50 -0300 Subject: [PATCH 05/19] Update Workflow --- .github/workflows/auto-merge-staging-into-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 4e9b15e6..80ea3bde 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -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: From 2bf4eba44d436e383fdf26c9bf808bea270a5652 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 13:31:50 -0300 Subject: [PATCH 06/19] Update Workflow --- .github/workflows/auto-merge-staging-into-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 4e9b15e6..80ea3bde 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -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: From e276c71461b35fd52da7a4d62b8a3137ca3d859e Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 13:59:42 -0300 Subject: [PATCH 07/19] Update workflow --- .github/workflows/auto-merge-staging-into-main.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 80ea3bde..0374e23d 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -2,7 +2,7 @@ name: Auto Merge Staging into Main on: schedule: - - cron: '0 2 * * *' # 2:00 UTC = 4:00 Europäische Zeit + - cron: '0 2 * * *' # 2:00 UTC = 4:00 CET workflow_dispatch: jobs: @@ -27,8 +27,9 @@ 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/main..origin/staging) -gt 0 ]; then + echo "❌ Staging ist hinter Main und benötigt ein Merge." exit 1 fi From 4a2eb72f0a5720f3d6efb1b2045fc4a20ec81222 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 14:10:18 -0300 Subject: [PATCH 08/19] Update workflow --- .github/workflows/auto-merge-staging-into-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index cbab05a2..2158c70f 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -28,7 +28,7 @@ jobs: id: check run: | git fetch origin - if [ $(git rev-list --count origin/main..origin/staging) -gt 0 ]; then + if [ $(git rev-list --count origin/staging..origin/main) -gt 0 ]; then echo "❌ Staging ist hinter Main und benötigt ein Merge." exit 1 fi From 344651dfc18e2c4d20d9051d705b507b78660d54 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 15:38:06 -0300 Subject: [PATCH 09/19] Update Workflow --- .github/workflows/auto-merge-staging-into-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 2158c70f..842b0e90 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -38,7 +38,7 @@ jobs: run: | git checkout main git merge origin/staging --no-ff --no-edit - git push origin main + git push origin main --force notify_failure: needs: merge From aca01b859f5003f94b3c3224a684d5ff96e91c0f Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 16:31:33 -0300 Subject: [PATCH 10/19] Auto PR --- .../auto-merge-staging-into-main.yml | 56 +++++++++++++++++-- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 842b0e90..9affb67f 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -33,12 +33,58 @@ jobs: exit 1 fi - - name: Merge staging into main - if: steps.check.outcome == 'success' + - name: Generate GitHub App Installation Token run: | - git checkout main - git merge origin/staging --no-ff --no-edit - git push origin main --force + echo "${{ secrets.IBCORNELSEN_APP_PRIVATE_KEY }}" > private-key.pem + chmod 600 private-key.pem + + # Generate JWT + now=$(date +%s) + exp=$((now + 600)) # 10 minutes validity + + header_base64=$(echo -n '{"alg":"RS256","typ":"JWT"}' | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') + payload_base64=$(echo -n "{\"iat\":$now,\"exp\":$exp,\"iss\":${{ secrets.IBCORNELSEN_APP_ID }}}" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') + header_payload="${header_base64}.${payload_base64}" + + signature=$(echo -n "$header_payload" | openssl dgst -sha256 -sign private-key.pem | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') + jwt="${header_payload}.${signature}" + + # Request Installation Token + response=$(curl -s -X POST \ + -H "Authorization: Bearer $jwt" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/app/installations/${{ secrets.IBCORNELSEN_INSTALLATION_ID }}/access_tokens) + + installation_token=$(echo "$response" | grep '"token"' | head -n 1 | cut -d '"' -f4) + + # Save the token as a GitHub environment variable + echo "INSTALLATION_TOKEN=$installation_token" >> $GITHUB_ENV + + # Clean up private key + rm -f private-key.pem + + - name: Create or update PR from staging → main + if: steps.check.outcome == 'success' + id: cpr + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ env.INSTALLATION_TOKEN }} # Use the installation token here + commit-message: "chore: auto-merge staging into main" + branch: auto-merge/staging-to-main + base: main + title: "Auto-merge staging into main" + body: | + This PR was created automatically by GitHub Actions. + It merges the latest `staging` into `main`. + draft: false + + - name: Enable auto-merge on PR + if: steps.cpr.outputs.pull-request-number != '' + uses: peter-evans/enable-pull-request-automerge@v3 + with: + token: ${{ env.INSTALLATION_TOKEN }} # Use the installation token here + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + merge-method: merge notify_failure: needs: merge From 3e09686cf69cb00bc7b15941e111a6fa2ea2aec9 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 16:34:28 -0300 Subject: [PATCH 11/19] Update --- .github/workflows/auto-merge-staging-into-main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 9affb67f..c04dbaff 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -59,6 +59,7 @@ jobs: # Save the token as a GitHub environment variable echo "INSTALLATION_TOKEN=$installation_token" >> $GITHUB_ENV + echo $installation_token # Clean up private key rm -f private-key.pem From 35c24b0380da5c299654a12bffc1d22642148a02 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 16:40:49 -0300 Subject: [PATCH 12/19] Update --- .../auto-merge-staging-into-main.yml | 35 ++----------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index c04dbaff..963f6d80 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -33,43 +33,12 @@ jobs: exit 1 fi - - name: Generate GitHub App Installation Token - run: | - echo "${{ secrets.IBCORNELSEN_APP_PRIVATE_KEY }}" > private-key.pem - chmod 600 private-key.pem - - # Generate JWT - now=$(date +%s) - exp=$((now + 600)) # 10 minutes validity - - header_base64=$(echo -n '{"alg":"RS256","typ":"JWT"}' | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') - payload_base64=$(echo -n "{\"iat\":$now,\"exp\":$exp,\"iss\":${{ secrets.IBCORNELSEN_APP_ID }}}" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') - header_payload="${header_base64}.${payload_base64}" - - signature=$(echo -n "$header_payload" | openssl dgst -sha256 -sign private-key.pem | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') - jwt="${header_payload}.${signature}" - - # Request Installation Token - response=$(curl -s -X POST \ - -H "Authorization: Bearer $jwt" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/app/installations/${{ secrets.IBCORNELSEN_INSTALLATION_ID }}/access_tokens) - - installation_token=$(echo "$response" | grep '"token"' | head -n 1 | cut -d '"' -f4) - - # Save the token as a GitHub environment variable - echo "INSTALLATION_TOKEN=$installation_token" >> $GITHUB_ENV - echo $installation_token - - # Clean up private key - rm -f private-key.pem - - name: Create or update PR from staging → main if: steps.check.outcome == 'success' id: cpr uses: peter-evans/create-pull-request@v4 with: - token: ${{ env.INSTALLATION_TOKEN }} # Use the installation token here + token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: auto-merge staging into main" branch: auto-merge/staging-to-main base: main @@ -83,7 +52,7 @@ jobs: if: steps.cpr.outputs.pull-request-number != '' uses: peter-evans/enable-pull-request-automerge@v3 with: - token: ${{ env.INSTALLATION_TOKEN }} # Use the installation token here + token: ${{ secrets.GITHUB_TOKEN }} pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} merge-method: merge From 10bc17963a938c4f22e5887ed06bb407e8ec37cd Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 16:48:34 -0300 Subject: [PATCH 13/19] Update --- .../auto-merge-staging-into-main.yml | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 963f6d80..1598cd7b 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -29,25 +29,36 @@ jobs: run: | git fetch origin if [ $(git rev-list --count origin/staging..origin/main) -gt 0 ]; then - echo "❌ Staging ist hinter Main und benötigt ein Merge." + echo "❌ Staging is behind main and requires manual merging." exit 1 fi - - name: Create or update PR from staging → main - if: steps.check.outcome == 'success' - id: cpr - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "chore: auto-merge staging into main" - branch: auto-merge/staging-to-main - base: main - title: "Auto-merge staging into main" - body: | - This PR was created automatically by GitHub Actions. - It merges the latest `staging` into `main`. - draft: false - + - name: Create or update PR from staging → main + if: steps.check.outcome == 'success' + id: cpr + run: | + # Checkout staging branch + git checkout staging + + # Create a new branch for the PR + git checkout -b auto-merge/staging-to-main + + # Push the new branch to the remote + git push origin auto-merge/staging-to-main + + # Create the pull request using the GitHub Action + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: auto-merge staging into main" + branch: auto-merge/staging-to-main + base: main + title: "Auto-merge staging into main" + body: | + This PR was created automatically by GitHub Actions. + It merges the latest `staging` into `main`. + draft: false + - name: Enable auto-merge on PR if: steps.cpr.outputs.pull-request-number != '' uses: peter-evans/enable-pull-request-automerge@v3 From 272b044157843fbb7fc2c347e2d97d16eda3c797 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 16:52:41 -0300 Subject: [PATCH 14/19] Update --- .../auto-merge-staging-into-main.yml | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 1598cd7b..06069452 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -33,31 +33,32 @@ jobs: exit 1 fi - - name: Create or update PR from staging → main - if: steps.check.outcome == 'success' - id: cpr - run: | - # Checkout staging branch - git checkout staging - - # Create a new branch for the PR - git checkout -b auto-merge/staging-to-main - - # Push the new branch to the remote - git push origin auto-merge/staging-to-main - - # Create the pull request using the GitHub Action - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "chore: auto-merge staging into main" - branch: auto-merge/staging-to-main - base: main - title: "Auto-merge staging into main" - body: | - This PR was created automatically by GitHub Actions. - It merges the latest `staging` into `main`. - draft: false + - name: Checkout auto-merge/staging-to-main + if: steps.check.outcome == 'success' + id: cpr + run: | + # Checkout staging branch + git checkout staging + + # Create a new branch for the PR + git checkout -b auto-merge/staging-to-main + + # Push the new branch to the remote + git push origin auto-merge/staging-to-main + + # Create the pull request using the GitHub Action + - name: Create PR from staging → main + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: auto-merge staging into main" + branch: auto-merge/staging-to-main + base: main + title: "Auto-merge staging into main" + body: | + This PR was created automatically by GitHub Actions. + It merges the latest `staging` into `main`. + draft: false - name: Enable auto-merge on PR if: steps.cpr.outputs.pull-request-number != '' From 75723d666ef956fe70e023524282d160ca5483bf Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 16:59:34 -0300 Subject: [PATCH 15/19] Update --- .../auto-merge-staging-into-main.yml | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 06069452..03ec7c09 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -33,21 +33,15 @@ jobs: exit 1 fi - - name: Checkout auto-merge/staging-to-main - if: steps.check.outcome == 'success' - id: cpr + - name: Checkout staging and create branch + id: create_branch run: | - # Checkout staging branch git checkout staging - - # Create a new branch for the PR git checkout -b auto-merge/staging-to-main - - # Push the new branch to the remote git push origin auto-merge/staging-to-main - - # Create the pull request using the GitHub Action + - name: Create PR from staging → main + id: create_pr uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -59,15 +53,16 @@ jobs: This PR was created automatically by GitHub Actions. It merges the latest `staging` into `main`. draft: false - + - name: Enable auto-merge on PR - if: steps.cpr.outputs.pull-request-number != '' + if: steps.create_pr.outputs.pull-request-number != '' uses: peter-evans/enable-pull-request-automerge@v3 with: - token: ${{ secrets.GITHUB_TOKEN }} - pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + token: ${{ secrets.GITHUB_TOKEN }} + pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }} merge-method: merge + notify_failure: needs: merge if: failure() From f778641be698c07dd383faf515a17b3d62b237d7 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 17:07:26 -0300 Subject: [PATCH 16/19] No Checkout --- .../auto-merge-staging-into-main.yml | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 03ec7c09..33951c18 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -1,8 +1,7 @@ name: Auto Merge Staging into Main - on: 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: jobs: @@ -13,17 +12,17 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - + - name: Set Git user run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - + - name: Fetch all branches run: | git fetch origin main git fetch origin staging - + - name: Check if main has commits not in staging id: check run: | @@ -32,28 +31,21 @@ jobs: echo "❌ Staging is behind main and requires manual merging." exit 1 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 id: create_pr uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: auto-merge staging into main" - branch: auto-merge/staging-to-main + branch: staging base: main title: "Auto-merge staging into main" body: | This PR was created automatically by GitHub Actions. It merges the latest `staging` into `main`. draft: false - + - name: Enable auto-merge on PR if: steps.create_pr.outputs.pull-request-number != '' uses: peter-evans/enable-pull-request-automerge@v3 @@ -61,8 +53,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }} merge-method: merge - - + notify_failure: needs: merge if: failure() @@ -71,10 +62,10 @@ jobs: - name: Send Discord notification on failure run: | 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 }} - + -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() @@ -83,6 +74,6 @@ jobs: - 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 }} \ No newline at end of file + -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 }} \ No newline at end of file From 73b44d574b566c007ceec0462c059913bf368ab1 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 17:11:54 -0300 Subject: [PATCH 17/19] Update --- .../auto-merge-staging-into-main.yml | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 33951c18..03ec7c09 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -1,7 +1,8 @@ name: Auto Merge Staging into Main + on: 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: jobs: @@ -12,17 +13,17 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - + - name: Set Git user run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - + - name: Fetch all branches run: | git fetch origin main git fetch origin staging - + - name: Check if main has commits not in staging id: check run: | @@ -31,21 +32,28 @@ jobs: echo "❌ Staging is behind main and requires manual merging." exit 1 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 id: create_pr uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: auto-merge staging into main" - branch: staging + branch: auto-merge/staging-to-main base: main title: "Auto-merge staging into main" body: | This PR was created automatically by GitHub Actions. It merges the latest `staging` into `main`. draft: false - + - name: Enable auto-merge on PR if: steps.create_pr.outputs.pull-request-number != '' uses: peter-evans/enable-pull-request-automerge@v3 @@ -53,7 +61,8 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }} merge-method: merge - + + notify_failure: needs: merge if: failure() @@ -62,10 +71,10 @@ jobs: - name: Send Discord notification on failure run: | 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 }} - + -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() @@ -74,6 +83,6 @@ jobs: - 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 }} \ No newline at end of file + -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 }} \ No newline at end of file From 4b9e7dda5fd55240c0ec6fbd212101afb8e787e4 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 17:14:28 -0300 Subject: [PATCH 18/19] ahhhhh --- .github/workflows/auto-merge-staging-into-main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index 03ec7c09..cc16f26e 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -36,8 +36,7 @@ jobs: - name: Checkout staging and create branch id: create_branch run: | - git checkout staging - git checkout -b auto-merge/staging-to-main + git checkout -b auto-merge/staging-to-main origin/staging git push origin auto-merge/staging-to-main - name: Create PR from staging → main From 76bd0bb5dd7072efcb2b9065b0072cab6185775d Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 17:18:45 -0300 Subject: [PATCH 19/19] hilfe --- .../auto-merge-staging-into-main.yml | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index cc16f26e..f233b3ad 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -33,33 +33,22 @@ jobs: exit 1 fi - - name: Checkout staging and create branch - id: create_branch - run: | - git checkout -b auto-merge/staging-to-main origin/staging - git push origin auto-merge/staging-to-main - - - name: Create PR from staging → main + - name: Create PR from staging to main id: create_pr - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "chore: auto-merge staging into main" - branch: auto-merge/staging-to-main - base: main - title: "Auto-merge staging into main" - body: | - This PR was created automatically by GitHub Actions. - It merges the latest `staging` into `main`. - draft: false + run: | + 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.pull-request-number != '' - uses: peter-evans/enable-pull-request-automerge@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }} - merge-method: merge + 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: