ci: 上传附件前删除同名旧附件(防止重复)
This commit is contained in:
1 parent
fd41de3bc5
commit
3cac1d5342
1 file changed
+15
-4
@@ -62,7 +62,18 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
ID="${{ steps.release.outputs.release_id }}"
|
ID="${{ steps.release.outputs.release_id }}"
|
||||||
curl -s -X POST \
|
API="https://git.vanusys.com/api/v1/repos/${{ github.repository }}"
|
||||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
AUTH="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
||||||
-F "attachment=@dsh-desktop-online.zip" \
|
# remove same-name old assets first
|
||||||
"https://git.vanusys.com/api/v1/repos/${{ github.repository }}/releases/${ID}/assets"
|
curl -s -H "$AUTH" "$API/releases/${ID}/assets" -o assets.json
|
||||||
|
python -c "
|
||||||
|
import json
|
||||||
|
for a in json.load(open('assets.json')):
|
||||||
|
if a['name'] == 'dsh-desktop-online.zip':
|
||||||
|
print(a['id'])
|
||||||
|
" > old_ids.txt
|
||||||
|
while read AID; do
|
||||||
|
curl -s -X DELETE -H "$AUTH" "$API/releases/${ID}/assets/${AID}" -o /dev/null
|
||||||
|
echo "deleted old asset $AID"
|
||||||
|
done < old_ids.txt
|
||||||
|
curl -s -X POST -H "$AUTH" -F "attachment=@dsh-desktop-online.zip" "$API/releases/${ID}/assets"
|
||||||
Reference in new issue
Block a user