From 8d5944f7759f505eaf5b62f0ccdca1c375a30192 Mon Sep 17 00:00:00 2001 From: anti Date: Sun, 12 Apr 2026 04:15:42 -0400 Subject: [PATCH] ci: implement automated RC flow and finalize optimizations on dev --- .gitea/workflows/ci.yml | 68 ++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 220e412..f23664e 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [dev, testing] + branches: [dev, testing, "temp/merge-*"] paths-ignore: - "**/*.md" - "docs/**" @@ -58,7 +58,6 @@ jobs: - run: pip install -e .[dev] - run: pytest -m "" - merge-to-testing: name: Merge dev → testing runs-on: ubuntu-latest @@ -80,34 +79,47 @@ jobs: git merge origin/dev --no-ff -m "ci: auto-merge dev → testing [skip ci]" git push origin testing - open-pr: - name: Open PR to main + prepare-merge-to-main: + name: Prepare Merge to Main runs-on: ubuntu-latest needs: test if: github.ref == 'refs/heads/testing' steps: - - name: Open PR via Gitea API + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.DECNET_PR_TOKEN }} + - name: Configure git run: | - echo "--- Checking for existing open PRs ---" - LIST_RESPONSE=$(curl -s \ - -H "Authorization: token ${{ secrets.DECNET_PR_TOKEN }}" \ - "https://git.resacachile.cl/api/v1/repos/anti/DECNET/pulls?state=open&head=anti:testing&base=main&limit=5") - echo "$LIST_RESPONSE" - EXISTING=$(echo "$LIST_RESPONSE" | python3 -c "import sys, json; print(len(json.load(sys.stdin)))") - echo "Open PRs found: $EXISTING" - if [ "$EXISTING" -gt "0" ]; then - echo "PR already open, skipping." - exit 0 - fi - echo "--- Creating PR ---" - CREATE_RESPONSE=$(curl -s -X POST \ - -H "Authorization: token ${{ secrets.DECNET_PR_TOKEN }}" \ - -H "Content-Type: application/json" \ - -d '{ - "title": "Auto PR: testing → main", - "head": "testing", - "base": "main", - "body": "All CI and security checks passed on both dev and testing. Review and merge when ready." - }' \ - "https://git.resacachile.cl/api/v1/repos/anti/DECNET/pulls") - echo "$CREATE_RESPONSE" + git config user.name "DECNET CI" + git config user.email "ci@decnet.local" + - name: Create temp branch and sync with main + run: | + git fetch origin main + git checkout -b temp/merge-testing-to-main + echo "--- Switched to temp branch, merging main into it ---" + git merge origin/main --no-edit || { echo "CONFLICT: Manual resolution required"; exit 1; } + git push origin temp/merge-testing-to-main --force + + finalize-merge-to-main: + name: Finalize Merge to Main + runs-on: ubuntu-latest + needs: test + if: startsWith(github.ref, 'refs/heads/temp/merge-') + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.DECNET_PR_TOKEN }} + - name: Configure git + run: | + git config user.name "DECNET CI" + git config user.email "ci@decnet.local" + - name: Merge RC into main + run: | + git fetch origin main + git checkout main + git merge ${{ github.ref }} --no-ff -m "ci: auto-merge testing → main [skip ci]" + git push origin main + echo "--- Cleaning up temp branch ---" + git push origin --delete ${{ github.ref_name }}