name: Java CI on: push: branches: - main pull_request: branches: - main jobs: build: runs-on: ubuntu-latest # container: # image: dockerp.com/openjdk:17-jdk-slim # 使用带有 JDK 17 的 Docker 镜像 steps: - name: Check Version #Docker run: | cat /proc/version # - name: Install curl # run: | # apt-get update # apt-get install -y curl - name: Change Download URL to NJU Mirror run: | # 替换为 NJU 的 APT 源 sed -i 's/archive.ubuntu.com/mirrors.nju.edu.cn/g' /etc/apt/sources.list # echo "deb https://mirror.nju.edu.cn/ubuntu/ noble main restricted universe multiverse" > /etc/apt/sources.list.d/ubuntu.sources # echo "deb https://mirror.nju.edu.cn/ubuntu/ noble-updates main restricted universe multiverse" >> /etc/apt/sources.list.d/ubuntu.sources # echo "deb https://mirror.nju.edu.cn/ubuntu/ noble-backports main restricted universe multiverse" >> /etc/apt/sources.list.d/ubuntu.sources # echo "deb https://mirror.nju.edu.cn/ubuntu/ noble-security main restricted universe multiverse" >> /etc/apt/sources.list.d/ubuntu.sources # - name: Add missing GPG keys for NJU mirror # run: | # # 添加公钥 3B4FE6ACC0B21F32 # curl -fsSL https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3B4FE6ACC0B21F32 | tee /etc/apt/trusted.gpg.d/nju-archive-key.asc # # # 添加公钥 871920D1991BC93C # curl -fsSL https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x871920D1991BC93C | tee /etc/apt/trusted.gpg.d/nju-archive-key.asc # # - name: Install gnupg # run: | # apt-get update --allow-unauthenticated --ignore-missing # apt-get install --allow-unauthenticated -y gnupg # - name: Add missing GPG keys for NJU mirror # run: | # # 导入公钥 3B4FE6ACC0B21F32 # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 # # # 导入公钥 871920D1991BC93C # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C # - name: Disable APT signature verification # run: | # echo "Acquire::https::mirror.nju.edu.cn::Verify-Peer false;" | tee /etc/apt/apt.conf.d/99disable-verify # echo "Acquire::https::mirror.nju.edu.cn::Verify-Host false;" | tee -a /etc/apt/apt.conf.d/99disable-verify - name: Apt Update run: | apt update - name: Install Node.js run: | # 更新 apt 包管理器并安装必要的工具 apt-get install -y curl gnupg2 lsb-release ca-certificates --allow-unauthenticated # 安装 Node.js 20.x #curl -fsSL https://deb.nodesource.com/setup_20.x | bash - #apt-get install -y nodejs apt-get install -y nodejs npm # 验证安装是否成功 node -v npm -v - name: Install JDK 21 run: | apt-get install -y openjdk-21-jdk - name: Checkout code uses: http://fly6516.synology.me:4000/Gitea_Action/checkout@v2 - name: Compile Java program run: | mkdir -p ./build/classes javac HelloWorld.java -d ./build/classes - name: List compiled files run: ls -la ./build/classes - name: Upload artifact uses: http://fly6516.synology.me:4000/Gitea_Action/upload-artifact@v2 with: name: java-classes path: ./build/classes