|
45 | 45 | - apt |
46 | 46 | - dl |
47 | 47 | - archive |
| 48 | + - cache |
48 | 49 | steps: |
49 | 50 |
|
50 | 51 | - name: "Install dependencies: lftp" |
|
71 | 72 |
|
72 | 73 | # Move top-level archive subdirs from source to destination |
73 | 74 | find source/*/archive/ -mindepth 1 -maxdepth 1 -exec mv -i -- "{}" destination/ \; |
| 75 | + elif [[ "$platform" == "cache" ]]; then |
| 76 | + # Mirror cache root directory directly |
| 77 | + pushd destination >/dev/null |
| 78 | + lftp -e "mirror --parallel=64; quit" "${source_of_truth}/${platform}" |
| 79 | + popd >/dev/null |
74 | 80 | else |
75 | 81 | # Mirror dists directly into ./destination |
76 | 82 | pushd destination >/dev/null |
@@ -162,6 +168,25 @@ jobs: |
162 | 168 | | xargs -n3 -d'\n' | sed -e 's/\s\+/\//' | sed "s/ /,/" | jq -cnR '[inputs | select(length>0)]' | jq >> $GITHUB_OUTPUT |
163 | 169 | echo 'EOF' >> $GITHUB_OUTPUT |
164 | 170 |
|
| 171 | + Cache-index: |
| 172 | + name: "Compare cache mirrors" |
| 173 | + needs: build |
| 174 | + outputs: |
| 175 | + matrix: ${{steps.json.outputs.JSON_CONTENT}} |
| 176 | + runs-on: ubuntu-24.04 |
| 177 | + steps: |
| 178 | + |
| 179 | + - name: "Get cache mirrors from database" |
| 180 | + id: json |
| 181 | + run: | |
| 182 | +
|
| 183 | + echo 'JSON_CONTENT<<EOF' >> $GITHUB_OUTPUT |
| 184 | + curl -H "Authorization: Token ${{ secrets.NETBOX_TOKEN }}" -H "Accept: application/json; indent=4" \ |
| 185 | + "${{ secrets.NETBOX_API }}/virtualization/virtual-machines/?limit=500&name__empty=false&tag=cache&status=active" \ |
| 186 | + | jq '.results[] | .name,.custom_fields["download_path_cache"],.id' | sed "s|null|cache|" | sed "s/\"//g" \ |
| 187 | + | xargs -n3 -d'\n' | sed -e 's/\s\+/\//' | sed "s/ /,/" | jq -cnR '[inputs | select(length>0)]' | jq >> $GITHUB_OUTPUT |
| 188 | + echo 'EOF' >> $GITHUB_OUTPUT |
| 189 | +
|
165 | 190 | Debs-beta: |
166 | 191 | name: "B" |
167 | 192 | runs-on: ubuntu-24.04 |
@@ -400,8 +425,67 @@ jobs: |
400 | 425 | path: status |
401 | 426 | if-no-files-found: ignore |
402 | 427 |
|
| 428 | + Cache: |
| 429 | + name: "C" |
| 430 | + runs-on: ubuntu-24.04 |
| 431 | + needs: [ Cache-index ] |
| 432 | + outputs: |
| 433 | + matrix: ${{needs.Cache-index.outputs.matrix}} |
| 434 | + if: ${{ needs.Cache-index.outputs.matrix != '[]' && needs.Cache-index.outputs.matrix != '' }} |
| 435 | + timeout-minutes: 7 |
| 436 | + strategy: |
| 437 | + fail-fast: false |
| 438 | + matrix: |
| 439 | + node: ${{fromJson(needs.Cache-index.outputs.matrix)}} |
| 440 | + |
| 441 | + steps: |
| 442 | + |
| 443 | + - uses: actions/download-artifact@v7 |
| 444 | + with: |
| 445 | + name: cache |
| 446 | + path: cache |
| 447 | + |
| 448 | + - name: "Install dependencies" |
| 449 | + uses: awalsh128/cache-apt-pkgs-action@latest |
| 450 | + with: |
| 451 | + packages: lftp |
| 452 | + version: 1.0 |
| 453 | + |
| 454 | + - name: "Check ${{ matrix.node }} " |
| 455 | + run: | |
| 456 | +
|
| 457 | + SERVER_URL=$(echo "${{ matrix.node }}" | cut -d"," -f1) |
| 458 | + SERVER_ID=$(echo "${{ matrix.node }}" | cut -d"," -f2) |
| 459 | + echo "SERVER_ID=${SERVER_ID}" >> $GITHUB_ENV |
| 460 | + mkdir -p compare; cd compare |
| 461 | + if curl --output /dev/null --silent --head --fail "https://${SERVER_URL}/cache/"; then |
| 462 | + timeout 5m lftp -e "mirror --parallel=16; exit" https://${SERVER_URL}/cache/ || exit_status=$? |
| 463 | + fi |
| 464 | + cd .. |
| 465 | + OUT=$(diff -rq compare cache || true) |
| 466 | + mkdir -p status |
| 467 | + if [[ -z "${OUT}" ]]; then |
| 468 | + echo "true" >> status/${SERVER_ID} |
| 469 | + echo "STATUS=true" >> $GITHUB_ENV |
| 470 | + elif [[ "${exit_status}" -eq 0 ]]; then |
| 471 | + echo "not_in_sync" >> status/${SERVER_ID} |
| 472 | + echo "${SERVER_URL}" >> status/${SERVER_ID} |
| 473 | + echo "STATUS=not_in_sync" >> $GITHUB_ENV |
| 474 | + elif [[ "${exit_status}" -eq 124 ]]; then |
| 475 | + echo "timeout" >> status/${SERVER_ID} |
| 476 | + echo "${SERVER_URL}" >> status/${SERVER_ID} |
| 477 | + echo "STATUS=not_in_sync" >> $GITHUB_ENV |
| 478 | + fi |
| 479 | +
|
| 480 | + - name: Upload ${{ env.STATUS }} for ${{ matrix.node }} |
| 481 | + uses: actions/upload-artifact@v6 |
| 482 | + with: |
| 483 | + name: cache-${{ env.SERVER_ID }} |
| 484 | + path: status |
| 485 | + if-no-files-found: ignore |
| 486 | + |
403 | 487 | download: |
404 | | - needs: [ Debs-beta,Debs-stable,Images-stable,Images-archive ] |
| 488 | + needs: [ Debs-beta,Debs-stable,Images-stable,Images-archive,Cache ] |
405 | 489 | runs-on: ubuntu-24.04 |
406 | 490 | steps: |
407 | 491 |
|
@@ -545,6 +629,38 @@ jobs: |
545 | 629 | netbox: ${{ secrets.NETBOX_TOKEN }} |
546 | 630 | netboxapi: ${{ secrets.NETBOX_API }} |
547 | 631 |
|
| 632 | + - name: Download All Artifacts |
| 633 | + uses: actions/download-artifact@v7 |
| 634 | + with: |
| 635 | + path: status |
| 636 | + pattern: cache* |
| 637 | + merge-multiple: true |
| 638 | + |
| 639 | + - name: "Grep only those that are in sync" |
| 640 | + run: | |
| 641 | + echo "# Not in sync" >> $GITHUB_STEP_SUMMARY |
| 642 | + grep not_in_sync status/* | cut -d":" -f1 | xargs awk 'FNR==2{print}' >> $GITHUB_STEP_SUMMARY |
| 643 | + echo "# Timeouts" >> $GITHUB_STEP_SUMMARY |
| 644 | + grep timeout status/* | cut -d":" -f1 | xargs awk 'FNR==2{print}' >> $GITHUB_STEP_SUMMARY |
| 645 | +
|
| 646 | + echo "failoverserver=$(grep true status/* | cut -d":" -f1 | cut -d"/" -f2 | sed ':a; N; s/\n/ /; ta') " >> $GITHUB_ENV |
| 647 | + echo "reloadKey=$(openssl rand -hex 16)" >> $GITHUB_ENV |
| 648 | + rm -rf status |
| 649 | +
|
| 650 | + - name: Cache |
| 651 | + uses: armbian/actions/make-yaml-redirector@main |
| 652 | + with: |
| 653 | + variant: cache |
| 654 | + failoverserver: "${{ env.failoverserver }}" |
| 655 | + port: 8084 |
| 656 | + geodb: "${{ env.GEODB }}" |
| 657 | + asndb: "${{ env.ASNDB }}" |
| 658 | + dl_map: "${{ env.DL_MAP }}" |
| 659 | + certDataPath: "${{ env.CERTPATH }}" |
| 660 | + reloadKey: ${{ env.reloadKey }} |
| 661 | + netbox: ${{ secrets.NETBOX_TOKEN }} |
| 662 | + netboxapi: ${{ secrets.NETBOX_API }} |
| 663 | + |
548 | 664 | Close: |
549 | 665 | needs: [ download ] |
550 | 666 | runs-on: ubuntu-24.04 |
@@ -596,10 +712,12 @@ jobs: |
596 | 712 | debs-* |
597 | 713 | dl-* |
598 | 714 | archive-* |
| 715 | + cache-* |
599 | 716 | apt |
600 | 717 | beta |
601 | 718 | dl |
602 | 719 | archive |
| 720 | + cache |
603 | 721 |
|
604 | 722 | - name: Install SSH key + known_hosts (task two) |
605 | 723 | uses: shimataro/ssh-key-action@v2 |
|
0 commit comments