更新.gitlab-ci.yml文件
This commit is contained in:
@@ -9,26 +9,38 @@
|
||||
image: golang:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
- deploy
|
||||
|
||||
format:
|
||||
stage: test
|
||||
script:
|
||||
- go fmt $(go list ./... | grep -v /vendor/)
|
||||
- go vet $(go list ./... | grep -v /vendor/)
|
||||
- go test -race $(go list ./... | grep -v /vendor/)
|
||||
|
||||
compile:
|
||||
build:
|
||||
# Use the official docker image.
|
||||
image: docker:cli
|
||||
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:
|
||||
- make
|
||||
artifacts:
|
||||
paths:
|
||||
- openai-api-route
|
||||
- docker build --pull -t "$DOCKER_IMAGE_NAME" .
|
||||
- docker push "$DOCKER_IMAGE_NAME"
|
||||
- |
|
||||
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:
|
||||
stage: deploy
|
||||
script: echo "Define your deployment script!"
|
||||
environment: production
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user