🐛 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)
This commit is contained in:
@@ -24,21 +24,23 @@ jobs:
|
||||
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${PREV_TAG}..${CURRENT_TAG}")
|
||||
fi
|
||||
|
||||
echo "$CHANGELOG" > changelog.txt
|
||||
echo "$CHANGELOG" > /tmp/changelog.txt
|
||||
echo "current_tag=$CURRENT_TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_TOKEN: ${{ gitea.token }}
|
||||
SERVER_URL: ${{ gitea.server_url }}
|
||||
REPOSITORY: ${{ gitea.repository }}
|
||||
run: |
|
||||
CURRENT_TAG=${{ steps.changelog.outputs.current_tag }}
|
||||
APP_NAME=$(jq -r '.name' package.json)
|
||||
CHANGELOG=$(cat changelog.txt)
|
||||
CHANGELOG=$(cat /tmp/changelog.txt)
|
||||
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
"https://gitea.pzetatouch.it/api/v1/repos/${{ gitea.repository }}/releases" \
|
||||
"$SERVER_URL/api/v1/repos/$REPOSITORY/releases" \
|
||||
-d "{
|
||||
\"tag_name\": \"$CURRENT_TAG\",
|
||||
\"name\": \"$APP_NAME $CURRENT_TAG\",
|
||||
|
||||
@@ -10,7 +10,9 @@ jobs:
|
||||
steps:
|
||||
- name: Delete merged branch
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_TOKEN: ${{ gitea.token }}
|
||||
SERVER_URL: ${{ gitea.server_url }}
|
||||
REPOSITORY: ${{ gitea.repository }}
|
||||
run: |
|
||||
BRANCH="${{ gitea.event.pull_request.head.ref }}"
|
||||
|
||||
@@ -19,8 +21,10 @@ jobs:
|
||||
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" \
|
||||
"https://gitea.pzetatouch.it/api/v1/repos/${{ gitea.repository }}/branches/$(python3 -c "import urllib.parse; print(urllib.parse.quote('$BRANCH', safe=''))")"
|
||||
"$SERVER_URL/api/v1/repos/$REPOSITORY/branches/$ENCODED_BRANCH"
|
||||
|
||||
echo "Branch eliminato: $BRANCH"
|
||||
|
||||
@@ -53,7 +53,9 @@ jobs:
|
||||
- name: Open issue if problems found
|
||||
if: steps.audit.outputs.vulnerabilities != '0' || steps.outdated.outputs.count != '0'
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_TOKEN: ${{ gitea.token }}
|
||||
SERVER_URL: ${{ gitea.server_url }}
|
||||
REPOSITORY: ${{ gitea.repository }}
|
||||
run: |
|
||||
VULNS="${{ steps.audit.outputs.vulnerabilities }}"
|
||||
OUTDATED="${{ steps.outdated.outputs.count }}"
|
||||
@@ -62,25 +64,14 @@ jobs:
|
||||
VULN_LIST=$(jq -r '.vulnerabilities | to_entries[] | "- \(.key): \(.value.severity)"' audit.json 2>/dev/null | head -20 || echo "N/A")
|
||||
OUTDATED_LIST=$(jq -r 'to_entries[] | "- \(.key): \(.value.current) → \(.value.latest)"' outdated.json 2>/dev/null | head -20 || echo "N/A")
|
||||
|
||||
BODY="## Dependency Check — $DATE
|
||||
|
||||
### Vulnerabilità (high/critical): $VULNS
|
||||
|
||||
\`\`\`
|
||||
$VULN_LIST
|
||||
\`\`\`
|
||||
|
||||
### Pacchetti obsoleti: $OUTDATED
|
||||
|
||||
\`\`\`
|
||||
$OUTDATED_LIST
|
||||
\`\`\`"
|
||||
printf '## Dependency Check — %s\n\n### Vulnerabilità (high/critical): %s\n\n```\n%s\n```\n\n### Pacchetti obsoleti: %s\n\n```\n%s\n```\n' \
|
||||
"$DATE" "$VULNS" "$VULN_LIST" "$OUTDATED" "$OUTDATED_LIST" > /tmp/body.md
|
||||
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
"https://gitea.pzetatouch.it/api/v1/repos/${{ gitea.repository }}/issues" \
|
||||
"$SERVER_URL/api/v1/repos/$REPOSITORY/issues" \
|
||||
-d "{
|
||||
\"title\": \"[$DATE] Dipendenze: $VULNS vulnerabilità, $OUTDATED obsoleti\",
|
||||
\"body\": $(echo "$BODY" | jq -Rs .)
|
||||
\"body\": $(jq -Rs . /tmp/body.md)
|
||||
}"
|
||||
|
||||
Reference in New Issue
Block a user