|
6 | 6 |
|
7 | 7 | env:
|
8 | 8 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
9 |
| - PULL_REPOSITORY: "${{ github.event.client_payload.pull_repository }}" # username/repository |
10 |
| - CDN_TAG: "${{ github.event.client_payload.cdn_tag }}" # folder on server |
| 9 | + PULL_REPOSITORY: "${{ github.event.client_payload.pull_repository || 'cli/cli' }}" # username/repository |
| 10 | + CDN_TAG: "${{ github.event.client_payload.cdn_tag || 'os' }}" # folder on server |
11 | 11 | PULL_TAG: "" # leave empty for latest
|
12 | 12 |
|
13 | 13 | jobs:
|
@@ -107,17 +107,40 @@ jobs:
|
107 | 107 | name: parts
|
108 | 108 | pattern: part*
|
109 | 109 | merge-multiple: true
|
110 |
| - - name: "Make JSON" |
| 110 | + - name: "Clean older files on servers" |
111 | 111 | id: json
|
112 | 112 | run: |
|
113 | 113 | LATEST=$(cat part*.json | jq -r '.[].tag' | sort | uniq)
|
114 | 114 | CDN_TAG=$(cat part*.json | jq -r '.[].cdn_tag' | sort | uniq)
|
115 | 115 | echo "Delete all except $LATEST on $CDN_TAG"
|
116 | 116 | tempfolder=$(mktemp -d)
|
117 |
| - rsync --delete -e \ |
118 |
| - "ssh -p 10023 -o StrictHostKeyChecking=accept-new" \ |
119 |
| - -rvP ${tempfolder}/ "[email protected]:/storage/www/cache/${CDN_TAG}" --exclude=${LATEST} |
120 | 117 |
|
| 118 | + # we use servers.json definitions that was build in main workflow |
| 119 | + # so we don't call API for every file |
| 120 | + for row in $( cat servers.json | jq -r '@base64'); do |
| 121 | + # Decode the base64 encoded JSON and extract values |
| 122 | + _jq() { |
| 123 | + echo ${row} | base64 --decode | jq -r ${1} |
| 124 | + } |
| 125 | + # Extract values from each item |
| 126 | + id=$(_jq '.id') |
| 127 | + name=$(_jq '.name') |
| 128 | + path=$(_jq '.custom_fields.path') |
| 129 | + port=$(_jq '.custom_fields.port') |
| 130 | + download_path_archive=$(_jq '.custom_fields.download_path_archive') |
| 131 | + download_path_debs=$(_jq '.custom_fields.download_path_debs') |
| 132 | + download_path_images=$(_jq '.custom_fields.download_path_images') |
| 133 | + known_hosts=$(_jq '.custom_fields.known_hosts') |
| 134 | + path=$(_jq '.custom_fields.path') |
| 135 | + port=$(_jq '.custom_fields.port') |
| 136 | + runners=$(_jq '.custom_fields.runners') |
| 137 | + username=$(_jq '.custom_fields.username') |
| 138 | + weight=$(_jq '.custom_fields.weight') |
| 139 | + # rsync |
| 140 | + rsync --delete -e \ |
| 141 | + "ssh -p ${port} -o StrictHostKeyChecking=accept-new" \ |
| 142 | + -rvP ${tempfolder}/ "${username}@${name}:${path}/cache/${CDN_TAG}" --exclude=${LATEST} |
| 143 | + done |
121 | 144 | - uses: geekyeggo/delete-artifact@v5
|
122 | 145 | with:
|
123 | 146 | name: |
|
|
0 commit comments