From 9da662f8d65aff4cf19fc412ac92e2d1286ae654 Mon Sep 17 00:00:00 2001 From: 247LIKE <54342887+247like@users.noreply.github.com> Date: Tue, 16 Dec 2025 09:59:25 +0800 Subject: [PATCH] Add GitHub Actions workflow for testing multiple containers --- .github/workflows/test.yml | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b6347e9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,58 @@ +name: Test Matrix + +on: [push, pull_request] + +jobs: + test-distros: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + container: + - 'debian:11' + - 'debian:12' + - 'ubuntu:22.04' + - 'alpine:latest' + - 'almalinux:9' # 推荐:CentOS 9 的完美替代 + - 'rockylinux:9' # 推荐:CentOS 9 的完美替代 + - 'centos:7' # 官方 CentOS 7 (需修复源) + - 'quay.io/centos/centos:stream9' # 官方 CentOS Stream 9 (原生可用) + + container: + image: ${{ matrix.container }} + options: --privileged + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + # === 关键:针对旧版 CentOS 的“起死回生”补丁 === + - name: Fix CentOS EOL Repos + run: | + # 如果是 CentOS 8 (已死),需要切到 vault 源 + if grep -q "CentOS Linux 8" /etc/os-release 2>/dev/null; then + sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* + fi + + # 如果是 CentOS 7 (已死),同样需要切到 vault 源 + if grep -q "CentOS Linux 7" /etc/os-release 2>/dev/null; then + sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Base.repo + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Base.repo + fi + + - name: Pre-install basic requirements + run: | + if [ -f /etc/alpine-release ]; then + apk add --no-cache curl sudo openssh-server + elif [ -f /etc/debian_version ]; then + apt-get update && apt-get install -y curl sudo openssh-server + elif [ -f /etc/redhat-release ]; then + # CentOS/Alma/Rocky 都在这里 + dnf install -y curl sudo openssh-server || yum install -y curl sudo openssh-server + fi + + - name: Run Init Script + run: | + chmod +x init.sh + ./init.sh --user=root --port=2222 --key-raw="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPQQDejyTCPJO3Jyw5UX9jmojb/zjgcqVuRO28fmpWU5" --no-update --bbr --delay-restart --yes --strict