| 1 | name: Setup APT mirrors |
| 2 | description: Configure Ubuntu package downloads with automatic mirror failover. |
| 3 | runs: |
| 4 | using: composite |
| 5 | steps: |
| 6 | - shell: bash |
| 7 | run: | |
| 8 | # Replace the existing Blacksmith mirror list as well as direct sources. |
| 9 | printf '%s\tpriority:%s\n' \ |
| 10 | https://archive.ubuntu.com/ubuntu 1 \ |
| 11 | https://mirrors.edge.kernel.org/ubuntu 2 \ |
| 12 | https://mirror.math.princeton.edu/pub/ubuntu 3 \ |
| 13 | | sudo tee /etc/apt/blacksmith-ubuntu-mirrors.txt > /dev/null |
| 14 | |
| 15 | # APT's mirror transport retries each file against the next server. |
| 16 | sudo find /etc/apt -maxdepth 2 -type f \( -name '*.list' -o -name '*.sources' \) \ |
| 17 | -exec sed -i -E \ |
| 18 | 's#https?://(([^/]+\.)?archive|security)\.ubuntu\.com/ubuntu/?#mirror+file:/etc/apt/blacksmith-ubuntu-mirrors.txt#g' {} + |
| 19 | |
| 20 | # Move on to a fallback before an unreachable server exhausts the job. |
| 21 | printf '%s\n' 'Acquire::http::Timeout "15";' 'Acquire::https::Timeout "15";' \ |
| 22 | | sudo tee /etc/apt/apt.conf.d/80-mirror-timeouts > /dev/null |