ci: implement automated RC flow and finalize optimizations on dev
This commit is contained in:
@@ -2,7 +2,7 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [dev, testing]
|
branches: [dev, testing, "temp/merge-*"]
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "**/*.md"
|
- "**/*.md"
|
||||||
- "docs/**"
|
- "docs/**"
|
||||||
@@ -58,7 +58,6 @@ jobs:
|
|||||||
- run: pip install -e .[dev]
|
- run: pip install -e .[dev]
|
||||||
- run: pytest -m ""
|
- run: pytest -m ""
|
||||||
|
|
||||||
|
|
||||||
merge-to-testing:
|
merge-to-testing:
|
||||||
name: Merge dev → testing
|
name: Merge dev → testing
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -80,34 +79,47 @@ jobs:
|
|||||||
git merge origin/dev --no-ff -m "ci: auto-merge dev → testing [skip ci]"
|
git merge origin/dev --no-ff -m "ci: auto-merge dev → testing [skip ci]"
|
||||||
git push origin testing
|
git push origin testing
|
||||||
|
|
||||||
open-pr:
|
prepare-merge-to-main:
|
||||||
name: Open PR to main
|
name: Prepare Merge to Main
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: test
|
needs: test
|
||||||
if: github.ref == 'refs/heads/testing'
|
if: github.ref == 'refs/heads/testing'
|
||||||
steps:
|
steps:
|
||||||
- name: Open PR via Gitea API
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.DECNET_PR_TOKEN }}
|
||||||
|
- name: Configure git
|
||||||
run: |
|
run: |
|
||||||
echo "--- Checking for existing open PRs ---"
|
git config user.name "DECNET CI"
|
||||||
LIST_RESPONSE=$(curl -s \
|
git config user.email "ci@decnet.local"
|
||||||
-H "Authorization: token ${{ secrets.DECNET_PR_TOKEN }}" \
|
- name: Create temp branch and sync with main
|
||||||
"https://git.resacachile.cl/api/v1/repos/anti/DECNET/pulls?state=open&head=anti:testing&base=main&limit=5")
|
run: |
|
||||||
echo "$LIST_RESPONSE"
|
git fetch origin main
|
||||||
EXISTING=$(echo "$LIST_RESPONSE" | python3 -c "import sys, json; print(len(json.load(sys.stdin)))")
|
git checkout -b temp/merge-testing-to-main
|
||||||
echo "Open PRs found: $EXISTING"
|
echo "--- Switched to temp branch, merging main into it ---"
|
||||||
if [ "$EXISTING" -gt "0" ]; then
|
git merge origin/main --no-edit || { echo "CONFLICT: Manual resolution required"; exit 1; }
|
||||||
echo "PR already open, skipping."
|
git push origin temp/merge-testing-to-main --force
|
||||||
exit 0
|
|
||||||
fi
|
finalize-merge-to-main:
|
||||||
echo "--- Creating PR ---"
|
name: Finalize Merge to Main
|
||||||
CREATE_RESPONSE=$(curl -s -X POST \
|
runs-on: ubuntu-latest
|
||||||
-H "Authorization: token ${{ secrets.DECNET_PR_TOKEN }}" \
|
needs: test
|
||||||
-H "Content-Type: application/json" \
|
if: startsWith(github.ref, 'refs/heads/temp/merge-')
|
||||||
-d '{
|
steps:
|
||||||
"title": "Auto PR: testing → main",
|
- uses: actions/checkout@v4
|
||||||
"head": "testing",
|
with:
|
||||||
"base": "main",
|
fetch-depth: 0
|
||||||
"body": "All CI and security checks passed on both dev and testing. Review and merge when ready."
|
token: ${{ secrets.DECNET_PR_TOKEN }}
|
||||||
}' \
|
- name: Configure git
|
||||||
"https://git.resacachile.cl/api/v1/repos/anti/DECNET/pulls")
|
run: |
|
||||||
echo "$CREATE_RESPONSE"
|
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 }}
|
||||||
|
|||||||
Reference in New Issue
Block a user