diff --git a/.gitea/workflows/build-ubuntu.yaml b/.gitea/workflows/build-ubuntu.yaml new file mode 100644 index 0000000..bf9141f --- /dev/null +++ b/.gitea/workflows/build-ubuntu.yaml @@ -0,0 +1,83 @@ +name: Build NGINX on Ubuntu + +on: + push: + pull_request: + branches: + - main + +jobs: + build-nginx: + runs-on: ubuntu-22.04 + steps: + - name: 检出代码 + uses: actions/checkout@v3 + + - name: 更新 apt 源 + run: sudo apt update + + - name: 安装编译工具和依赖 + run: | + sudo apt install -y gcc make libpcre3-dev zlib1g-dev libssl-dev + + - name: 配置构建 + run: | + auto/configure + + - name: 编译 NGINX + run: | + make + + - name: 安装 NGINX + run: | + sudo make install + + - name: 测试 NGINX 运行 + run: | + sudo /usr/local/nginx/sbin/nginx + curl -v localhost || true + + - name: 停止 NGINX 服务 + run: | + sudo /usr/local/nginx/sbin/nginx -s stop || true + + - name: 创建 Dockerfile + run: | + cat > Dockerfile << 'EOF' + FROM ubuntu:22.04 + + # 安装依赖 + RUN apt-get update && \ + apt-get install -y libpcre3 zlib1g libssl1.1 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + + # 复制编译好的 nginx + COPY /usr/local/nginx /usr/local/nginx + + # 暴露端口 + EXPOSE 80 443 + + # 设置工作目录 + WORKDIR /usr/local/nginx + + # 启动 nginx + CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"] + EOF + + - name: 设置 Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: 登录到 Harbor + uses: docker/login-action@v2 + with: + registry: ${{ secrets.HARBOR_REGISTRY }} + username: ${{ secrets.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_PASSWORD }} + + - name: 构建并推送 Docker 镜像 + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ secrets.HARBOR_REGISTRY }}/nginx/nginx:${{ github.sha }},${{ secrets.HARBOR_REGISTRY }}/nginx/nginx:latest diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml deleted file mode 100644 index 43a9744..0000000 --- a/.gitea/workflows/build.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Gitea Actions Demo -run-name: ${{ github.actor }} is testing out Gitea Actions 🚀 -on: [push] -jobs: - Explore-Gitea-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v3 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}."