diff --git a/.gitea/workflows/build-ubuntu.yaml b/.gitea/workflows/build-ubuntu.yaml index 19a3139..15fbba3 100644 --- a/.gitea/workflows/build-ubuntu.yaml +++ b/.gitea/workflows/build-ubuntu.yaml @@ -14,7 +14,7 @@ defaults: shell: 'bash -Eeo pipefail -x {0}' jobs: - build-nginx: + build-and-push: runs-on: ubuntu-22.04 steps: @@ -104,39 +104,11 @@ jobs: echo "停止 NGINX..." sudo /usr/local/nginx/sbin/nginx -s quit - - name: 准备构建产物 + - name: 准备构建上下文 run: | echo "复制 nginx 文件到构建上下文..." sudo cp -r /usr/local/nginx ./nginx-install sudo chown -R $(whoami):$(whoami) ./nginx-install - - # 打包构建产物供后续步骤使用 - tar -czf nginx-install.tar.gz ./nginx-install - - - name: 上传构建产物 - uses: actions/upload-artifact@v3 - with: - name: nginx-install - path: nginx-install.tar.gz - retention-days: 1 - - build-docker-image: - needs: build-nginx - runs-on: ubuntu-22.04 - - steps: - - name: 检出代码 - uses: actions/checkout@v4 - - - name: 下载构建产物 - uses: actions/download-artifact@v3 - with: - name: nginx-install - - - name: 准备构建上下文 - run: | - tar -xzf nginx-install.tar.gz - ls -la - name: 创建 Dockerfile run: | @@ -182,31 +154,6 @@ jobs: echo "构建 Docker 镜像..." docker build -t nginx-local:latest . - - name: 保存 Docker 镜像 - run: | - docker save nginx-local:latest > nginx-image.tar - - - name: 上传 Docker 镜像 - uses: actions/upload-artifact@v3 - with: - name: nginx-docker-image - path: nginx-image.tar - retention-days: 1 - - push-to-harbor: - needs: build-docker-image - runs-on: ubuntu-22.04 - - steps: - - name: 下载 Docker 镜像 - uses: actions/download-artifact@v3 - with: - name: nginx-docker-image - - - name: 加载 Docker 镜像 - run: | - docker load < nginx-image.tar - - name: 登录到 Harbor run: | echo "登录到 Harbor 仓库..." @@ -228,7 +175,7 @@ jobs: docker rmi ${{ secrets.HARBOR_REGISTRY }}/test/nginx:latest || true deploy-to-kubernetes: - needs: push-to-harbor + needs: build-and-push runs-on: ubuntu-22.04 if: github.ref == 'refs/heads/main' && github.event_name == 'push'