-
Notifications
You must be signed in to change notification settings - Fork 7
104 lines (88 loc) · 3.43 KB
/
ci.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Clean release assets
on:
push:
branches:
- "post-actions"
jobs:
clean-release:
runs-on: ubuntu-latest
env:
RELEASE_DATA: ""
steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Get latest release info
# id: get_latest_release
# uses: octokit/graphql-action@v2.x
# with:
# query: |
# query release($owner:String!,$repo:String!) {
# repository(owner:$owner,name:$repo) {
# releases(first:1) {
# nodes {
# releaseAssets(first:20) {
# nodes {
# id
# name
# }
# }
# }
# }
# }
# }
# variables: |
# owner: ${{ github.event.repository.owner.name }}
# repo: ${{ github.event.repository.name }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - uses: octokit/request-action@v2.x
# id: get_latest_release
# with:
# route: GET /repos/${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}/releases/latest
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - run: |
# echo '${{ steps.get_latest_release.outputs.data }}' | jq '.[0] | .assets | map(select(.name | endswith(".blockmap")).id)'
- name: Get the release data
id: releases_data
env:
HOST: "https://api.github.com"
ENDPOINT: "/repos/${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}/releases"
run: |
data=$(
curl -X GET -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"${HOST}${ENDPOINT}"
)
data=$(echo "${data}" | jq '.[0] | {name, id, assets: (.assets | map({name, id}))} | tostring')
echo "release_data=${data}" >> $GITHUB_OUTPUT
- name: Read the output
run: |
echo "${{ steps.releases_data.outputs.release_data }}" | jq '.'
# - name: Filter requested data
# id: jq_filter
# run: |
# blockmaps=$(
# echo '${{ steps.releases_data.outputs.release_data }}' | jq \
# .[0] | .assets | map(select(.name | endswith(".blockmap")).id) | "\"" + . + "\"") | join(" ")'
# )
# echo "( ${blockmaps} )"
# echo "blockmap_list=( ${blockmaps} )" >> $GITHUB_OUTPUT
# - name: Remove the blockmap files
# env:
# HOST: "https://api.github.com"
# ENDPOINT: "/repos/${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}/releases/assets/"
# run: |
# assets_array="${{ steps.jq_filter.outputs.blockmap_list }}"
# assets_array="${assets_array#(}"
# assets_array="${assets_array%)}"
# # Convert the array string to an actual array
# IFS=', ' read -ra assets <<< "$assets_array"
# # Iterate over the array elements
# echo "Iterating over the assets:"
# for asset_id in "${assets[@]}"; do
# echo "Deleting asset with ID: $asset_id"
# curl -X DELETE -s \
# -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
# "${HOST}${ENDPOINT}$asset_id"
# done