From 8772968de49736840e2a4bb3ec58d92fbdf678e8 Mon Sep 17 00:00:00 2001 From: DragonSlayer_14 Date: Sun, 13 Sep 2026 14:26:01 +0200 Subject: [PATCH] =?UTF-8?q?Feat:=20F=C3=BCgt=20automatischen=20PR-Workflow?= =?UTF-8?q?=20f=C3=BCr=20Testing=E2=86=92Main=20hinzu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01AjPGeW28DpjnMkuvLSRTKv --- .gitea/workflows/testing-to-main-pr.yaml | 111 +++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .gitea/workflows/testing-to-main-pr.yaml diff --git a/.gitea/workflows/testing-to-main-pr.yaml b/.gitea/workflows/testing-to-main-pr.yaml new file mode 100644 index 0000000..f26a71d --- /dev/null +++ b/.gitea/workflows/testing-to-main-pr.yaml @@ -0,0 +1,111 @@ +name: Auto-PR (Testing → Main) + +on: + push: + branches: + - testing + +jobs: + create-pr: + name: Erstelle automatisch PR von testing nach main + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Prüfe auf bereits offenen PR nach main + id: check_pr + env: + GITEA_URL: ${{ gitea.server_url || github.server_url }} + REPO: ${{ gitea.repository || github.repository }} + TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }} + run: | + OPEN_PRS=$(curl -s -H "Authorization: token ${TOKEN}" "${GITEA_URL}/api/v1/repos/${REPO}/pulls?state=open&limit=50") + EXISTS=$(echo "$OPEN_PRS" | jq -r '[.[] | select(.base.ref == "main" and .head.ref == "testing")] | length') + echo "Bereits offene testing→main PRs: ${EXISTS}" + echo "exists=${EXISTS}" >> "$GITHUB_OUTPUT" + + - name: Ermittle Versionen auf main & testing + id: versions + if: steps.check_pr.outputs.exists == '0' + run: | + git fetch origin main + MAIN_VERSION="$(git show origin/main:Cargo.toml | sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)" + TESTING_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" + echo "Version auf main: ${MAIN_VERSION} / Version auf testing: ${TESTING_VERSION}" + echo "main_version=${MAIN_VERSION}" >> "$GITHUB_OUTPUT" + echo "testing_version=${TESTING_VERSION}" >> "$GITHUB_OUTPUT" + + - name: Ermittle geänderte Kategorien (main...testing) + id: categories + if: steps.check_pr.outputs.exists == '0' && steps.versions.outputs.main_version == steps.versions.outputs.testing_version + run: | + CHANGED_FILES="$(git diff --name-only origin/main...HEAD)" + echo "Geänderte Dateien main...testing:" + echo "$CHANGED_FILES" + + WORKFLOWS="false" + CONFIG="false" + DOCS="false" + + if echo "$CHANGED_FILES" | grep -q '^\.gitea/workflows/'; then + WORKFLOWS="true" + fi + if echo "$CHANGED_FILES" | grep -qE '^(renovate\.json|qodana\.yaml|Cargo\.toml|Cargo\.lock|\.cargo/)'; then + CONFIG="true" + fi + if echo "$CHANGED_FILES" | grep -qE '(^|/)[^/]+\.md$|^LICENSE$'; then + DOCS="true" + fi + + echo "workflows=${WORKFLOWS}" >> "$GITHUB_OUTPUT" + echo "config=${CONFIG}" >> "$GITHUB_OUTPUT" + echo "docs=${DOCS}" >> "$GITHUB_OUTPUT" + + - name: Bestimme PR-Titel + id: title + if: steps.check_pr.outputs.exists == '0' + run: | + if [ "${{ steps.versions.outputs.main_version }}" != "${{ steps.versions.outputs.testing_version }}" ]; then + TITLE="Merge testing in main: Release ${{ steps.versions.outputs.testing_version }}" + else + PARTS=() + [ "${{ steps.categories.outputs.workflows }}" = "true" ] && PARTS+=("Workflows") + [ "${{ steps.categories.outputs.config }}" = "true" ] && PARTS+=("Konfigurationen") + [ "${{ steps.categories.outputs.docs }}" = "true" ] && PARTS+=("Dokumentation") + + if [ ${#PARTS[@]} -eq 0 ]; then + TITLE="Merge testing in main" + else + JOINED="" + for PART in "${PARTS[@]}"; do + if [ -z "$JOINED" ]; then + JOINED="$PART" + else + JOINED="${JOINED} & ${PART}" + fi + done + TITLE="Merge testing in main: ${JOINED} aktualisiert" + fi + fi + echo "Ermittelter PR-Titel: ${TITLE}" + echo "title=${TITLE}" >> "$GITHUB_OUTPUT" + + - name: Erstelle PR (testing -> main) + if: steps.check_pr.outputs.exists == '0' + env: + GITEA_URL: ${{ gitea.server_url || github.server_url }} + REPO: ${{ gitea.repository || github.repository }} + TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }} + TITLE: ${{ steps.title.outputs.title }} + run: | + PAYLOAD=$(jq -n --arg title "$TITLE" --arg head "testing" --arg base "main" \ + '{title: $title, head: $head, base: $base}') + curl -f -s -S -X POST \ + -H "Authorization: token ${TOKEN}" \ + -H "Content-Type: application/json" \ + -d "$PAYLOAD" \ + "${GITEA_URL}/api/v1/repos/${REPO}/pulls" + echo "PR erstellt: ${TITLE}"