-
-
Notifications
You must be signed in to change notification settings - Fork 3
55 lines (44 loc) · 1.83 KB
/
zip.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Upload Scripts Zip to Latest Release
on:
push:
paths:
- "source/zip/carchscripts.zip"
permissions:
contents: write
jobs:
upload_zip_to_release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Latest Release Info
id: get_latest_release_info
run: |
latest_release=$(curl -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/latest)
upload_url=$(echo "$latest_release" | jq -r '.upload_url' | sed 's/{?name,label}//')
release_id=$(echo "$latest_release" | jq -r '.id')
echo "upload_url=$upload_url" >> $GITHUB_ENV
echo "release_id=$release_id" >> $GITHUB_ENV
- name: Remove Existing carchscripts.zip Asset (if present)
run: |
assets=$(curl -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/$release_id/assets)
asset_id=$(echo "$assets" | jq -r '.[] | select(.name == "carchscripts.zip") | .id')
if [ -n "$asset_id" ]; then
echo "Removing existing carchscripts.zip asset with ID $asset_id"
curl -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/assets/$asset_id
else
echo "No existing carchscripts.zip asset found."
fi
- name: Upload Zip File to Latest Release
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/zip" \
--data-binary @source/zip/carchscripts.zip \
"$upload_url?name=carchscripts.zip"