update docker push
Some checks failed
Build NGINX on Ubuntu / build-nginx (push) Failing after 1m36s
Some checks failed
Build NGINX on Ubuntu / build-nginx (push) Failing after 1m36s
This commit is contained in:
parent
d02502e640
commit
9e13f6dba0
@ -98,16 +98,12 @@ jobs:
|
||||
|
||||
echo "检查 NGINX 进程..."
|
||||
ps aux | grep nginx
|
||||
|
||||
echo "测试 HTTP 连接..."
|
||||
echo "测试 HTTP 连接..."
|
||||
curl -v localhost || echo "HTTP 测试失败,但继续执行"
|
||||
|
||||
echo "停止 NGINX..."
|
||||
sudo /usr/local/nginx/sbin/nginx -s quit
|
||||
|
||||
- name: 设置 Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: 创建 Dockerfile
|
||||
run: |
|
||||
cat > Dockerfile << 'EOF'
|
||||
@ -147,21 +143,28 @@ jobs:
|
||||
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]
|
||||
EOF
|
||||
|
||||
- name: 构建 Docker 镜像
|
||||
run: |
|
||||
echo "构建 Docker 镜像..."
|
||||
docker build -t nginx-local:latest .
|
||||
|
||||
- name: 登录到 Harbor
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ secrets.HARBOR_REGISTRY }}
|
||||
username: ${{ secrets.HARBOR_USERNAME }}
|
||||
password: ${{ secrets.HARBOR_PASSWORD }}
|
||||
run: |
|
||||
echo "登录到 Harbor 仓库..."
|
||||
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login ${{ secrets.HARBOR_REGISTRY }} -u "${{ secrets.HARBOR_USERNAME }}" --password-stdin
|
||||
|
||||
- name: 构建并推送 Docker 镜像
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.HARBOR_REGISTRY }}/nginx/nginx:${{ github.sha }}
|
||||
${{ secrets.HARBOR_REGISTRY }}/nginx/nginx:latest
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
- name: 标记并推送 Docker 镜像
|
||||
run: |
|
||||
echo "标记镜像..."
|
||||
docker tag nginx-local:latest ${{ secrets.HARBOR_REGISTRY }}/test/nginx:${{ github.sha }}
|
||||
docker tag nginx-local:d'datest ${{ secrets.HARBOR_REGISTRY }}/test/nginx:latest
|
||||
|
||||
echo "推送镜像..."
|
||||
docker push ${{ secrets.HARBOR_REGISTRY }}/test/nginx:${{ github.sha }}
|
||||
docker push ${{ secrets.HARBOR_REGISTRY }}/test/nginx:latest
|
||||
|
||||
echo "清理本地镜像..."
|
||||
docker rmi nginx-local:latest || true
|
||||
docker rmi ${{ secrets.HARBOR_REGISTRY }}/test/nginx:${{ github.sha }} || true
|
||||
docker rmi ${{ secrets.HARBOR_REGISTRY }}/test/nginx:latest || true
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user