Files
CoHaiSe-CLOUD/.github/workflows/pr.yml
T
Esiah 293cd95ba6
PR — Ouverture automatique / create-pr (push) Canceled after 0s
fix(api): folder traversal for shared subfolders, rehome folders on user deletion
- GET /folders: allow listing children of intermediate folders leading to a
  shared descendant (canTraverse), filter children in application code since
  MariaDB forbids correlated recursive CTEs
- Admin user deletion: shared folders are transferred to their best permission
  holder (admin > write > read, oldest); unshared folders are soft-deleted
  with their subtree; a shared child whose parent disappears is moved to root;
  permissions and stars of the deleted account are cleaned up
- CI: label runners as [self-hosted, cohaise-cloud] to match the new dedicated
  gitea-runner
2026-10-19 12:08:23 +02:00

55 lines
1.8 KiB
YAML

name: PR — Ouverture automatique
on:
push:
branches-ignore: [main]
workflow_dispatch:
jobs:
create-pr:
runs-on: [self-hosted, cohaise-cloud]
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Ouvrir (ou vérifier) la pull request
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API: ${{ github.server_url }}/api/v1
REPO: ${{ github.repository }}
BRANCH: ${{ github.ref_name }}
run: |
set -eu
if [ "$BRANCH" = "main" ]; then
echo "main est la base : aucune PR à ouvrir."
exit 0
fi
title=$(git log -1 --pretty=%s)
body=$(git log -1 --pretty=%b)
[ -n "$body" ] || body="PR automatique de $BRANCH vers main."
open=$(curl -fsS -H "Authorization: token $GITEA_TOKEN" \
"$API/repos/$REPO/pulls?state=open&limit=50" \
| python3 -c 'import json,os,sys; b=os.environ["BRANCH"]; print(sum(1 for p in json.load(sys.stdin) if p.get("head", {}).get("ref") == b))')
if [ "$open" -gt 0 ]; then
echo "Une PR est déjà ouverte pour $BRANCH."
exit 0
fi
python3 - "$BRANCH" "$title" "$body" <<'PY' > /tmp/pr.json
import json, sys
branch, title, body = sys.argv[1], sys.argv[2], sys.argv[3]
print(json.dumps({"base": "main", "head": branch, "title": title, "body": body}))
PY
curl -fsS -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
--data @/tmp/pr.json \
"$API/repos/$REPO/pulls"
echo "PR créée."