kind: pipeline type: docker name: Build Hexo-Async-Offends-Blog trigger: event: include: - custom steps: - name: Hexo-Async-Offends-Blog image: docker:dind volumes: - name: dockersock path: /var/run/docker.sock - name: kubectl path: /usr/local/bin/kubectl - name: config path: /root/.kube/config environment: DOCKER_USERNAME: from_secret: DOCKER_USERNAME DOCKER_PASSWORD: from_secret: DOCKER_PASSWORD REGISTRY: from_secret: REGISTRY REPO: from_secret: REPO BUILD: from_secret: BUILD commands: - docker login $REGISTRY -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - | if [ -z "$BUILD" ]; then echo -e "\e[31m变量未指定,请检查Secret\e[0m" exit 1 else if [ -n "$BUILD" ] && { [ "$BUILD" = Hexo-async-offends ] || [ "$BUILD" = "All" ]; }; then echo -e "\033[32m开始构建\033[0m" cd /drone/src/ \ && docker build --build-arg IMAGENAME=registry.cn-hangzhou.aliyuncs.com/offends/hexo:hexo-async -t $REPO:hexo-async-offends -f Dockerfile-hexo-async-offends --no-cache . \ && docker push $REPO:hexo-async-offends \ && kubectl -n blog rollout restart deployment blog else echo -e "\033[33m不构建,跳过\033[0m" fi if [ -n "$BUILD" ] && { [ "$BUILD" = Gateway-kubernetes ] || [ "$BUILD" = "All" ]; }; then echo -e "\033[32m开始构建\033[0m" cd /drone/src/gateway \ && docker build --build-arg IMAGENAME=registry.cn-hangzhou.aliyuncs.com/offends/hexo:nginx-alpine-slim -t $REPO:gateway-kubernetes -f Dockerfile-kubernetes --no-cache . \ && docker push $REPO:gateway-kubernetes else echo -e "\033[33m不构建,跳过\033[0m" fi fi volumes: - name: dockersock host: path: /var/run/docker.sock - name: kubectl host: path: /usr/local/bin/kubectl - name: config host: path: /root/.kube/config --- kind: pipeline type: docker name: Build Gateway-docker trigger: event: include: - custom steps: - name: Gateway-docker image: docker:dind volumes: - name: dockersock path: /var/run/docker.sock environment: DOCKER_USERNAME: from_secret: DOCKER_USERNAME DOCKER_PASSWORD: from_secret: DOCKER_PASSWORD REGISTRY: from_secret: REGISTRY REPO: from_secret: REPO BUILD: from_secret: BUILD commands: - | if [ -z "$BUILD" ]; then echo -e "\e[31m变量未指定,请检查Secret\e[0m" exit 1 else if [ -n "$BUILD" ] && [ "$BUILD" = Gateway-docker ]; then echo -e "\033[32m开始构建\033[0m" cd /drone/src/gateway \ && docker login $REGISTRY -u $DOCKER_USERNAME -p $DOCKER_PASSWORD \ && docker build --build-arg IMAGENAME=registry.cn-hangzhou.aliyuncs.com/offends/hexo:nginx-alpine-slim -t $REPO:gateway-docker -f Dockerfile-docker --no-cache . \ && docker push $REPO:gateway-docker else echo -e "\033[33m不构建,跳过\033[0m" fi fi volumes: - name: dockersock host: path: /var/run/docker.sock