更新.gitlab-ci.yml文件

This commit is contained in:
2024-04-08 03:21:24 +00:00
parent e6ff1f5ca4
commit 34aa4babc4

View File

@@ -9,26 +9,38 @@
image: golang:latest image: golang:latest
stages: stages:
- test
- build - build
- deploy - deploy
format: build:
stage: test # Use the official docker image.
script: image: docker:cli
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
- go test -race $(go list ./... | grep -v /vendor/)
compile:
stage: build stage: build
services:
- docker:dind
variables:
DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# All branches are tagged with $DOCKER_IMAGE_NAME (defaults to commit ref slug)
# Default branch is also tagged with `latest`
script: script:
- make - docker build --pull -t "$DOCKER_IMAGE_NAME" .
artifacts: - docker push "$DOCKER_IMAGE_NAME"
paths: - |
- openai-api-route if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
docker tag "$DOCKER_IMAGE_NAME" "$CI_REGISTRY_IMAGE:latest"
docker push "$CI_REGISTRY_IMAGE:latest"
fi
# Run this job in a branch where a Dockerfile exists
rules:
- if: $CI_COMMIT_BRANCH
exists:
- Dockerfile
deploy: deploy:
stage: deploy stage: deploy
script: echo "Define your deployment script!" script: echo "Define your deployment script!"
environment: production environment: production