fix: make release delete step resilient + check GITEA_TOKEN
- Skip delete step gracefully if no releases exist - Check GITEA_TOKEN is set before attempting API calls - Add clear error message if secret is missing 💘 Generated with Crush Assisted-by: GLM-5.1 via Crush <crush@charm.land>
This commit is contained in:
@@ -76,19 +76,31 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
|
echo "Warning: GITEA_TOKEN not set, skipping delete"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
|
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
|
||||||
curl -s -H "Authorization: token ${GITEA_TOKEN}" "${API}" | grep -o '"id":[0-9]*' | while read line; do
|
RELEASES=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" "${API}" 2>/dev/null || echo "")
|
||||||
ID=$(echo "$line" | grep -o '[0-9]*')
|
if [ -n "$RELEASES" ]; then
|
||||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API}/${ID}"
|
echo "$RELEASES" | grep -o '"id":[0-9]*' | while read line; do
|
||||||
echo "Deleted release ${ID}"
|
ID=$(echo "$line" | grep -o '[0-9]*')
|
||||||
done
|
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API}/${ID}" > /dev/null 2>&1 || true
|
||||||
|
echo "Deleted release ${ID}"
|
||||||
|
done || true
|
||||||
|
fi
|
||||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/tags/latest" 2>/dev/null || true
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/tags/latest" > /dev/null 2>&1 || true
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
|
echo "Error: GITEA_TOKEN secret is not configured."
|
||||||
|
echo "Go to Settings > Actions > Secrets and add GITEA_TOKEN"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
VERSION=${{ steps.info.outputs.version }}
|
VERSION=${{ steps.info.outputs.version }}
|
||||||
SHA=${{ steps.info.outputs.sha }}
|
SHA=${{ steps.info.outputs.sha }}
|
||||||
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
|
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
|
||||||
|
|||||||
Reference in New Issue
Block a user