Files
LucaZanni f1305498c1 🐛 fix(ci): correggi URL istanza, token e struttura YAML nei workflow condivisi
- Sostituito URL hardcoded con ${{ gitea.server_url }} (portabilità)
- Sostituito ${{ secrets.GITEA_TOKEN }} con ${{ gitea.token }} (token automatico)
- Aggiunto env SERVER_URL/REPOSITORY per evitare espressioni inline nei curl
- Fix dependency-check: rimosso BODY multi-riga (bug YAML run:|) → printf + /tmp/body.md
- Fix auto-release: changelog su /tmp/changelog.txt (evita collisione workspace)
- Fix branch-cleanup: encoding branch via variabile (sicurezza shell)
2026-03-26 07:01:34 +01:00

31 lines
920 B
YAML

name: Branch Cleanup
on:
workflow_call:
jobs:
branch-cleanup:
runs-on: ubuntu-latest
if: gitea.event.pull_request.merged == true
steps:
- name: Delete merged branch
env:
GITEA_TOKEN: ${{ gitea.token }}
SERVER_URL: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
BRANCH="${{ gitea.event.pull_request.head.ref }}"
if [[ "$BRANCH" == "main" || "$BRANCH" == "master" || "$BRANCH" == "develop" ]]; then
echo "Branch protetto, skip: $BRANCH"
exit 0
fi
ENCODED_BRANCH=$(python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1], safe=''))" "$BRANCH")
curl -s -X DELETE \
-H "Authorization: token $GITEA_TOKEN" \
"$SERVER_URL/api/v1/repos/$REPOSITORY/branches/$ENCODED_BRANCH"
echo "Branch eliminato: $BRANCH"