ci-fix
This commit is contained in:
parent
a862bae489
commit
a3e71fe3f8
|
@ -1,38 +1,19 @@
|
||||||
# This file is a template, and might need editing before it works on your project.
|
---
|
||||||
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
image: dokku/ci-docker-image
|
||||||
# https://docs.gitlab.com/ee/development/cicd/templates.html
|
|
||||||
# This specific template is located at:
|
|
||||||
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml
|
|
||||||
|
|
||||||
# Build a Docker image with CI/CD and push to the GitLab registry.
|
stages:
|
||||||
# Docker-in-Docker documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
|
- deploy
|
||||||
#
|
|
||||||
# This template uses one generic job with conditional builds
|
|
||||||
# for the default branch and all other (MR) branches.
|
|
||||||
|
|
||||||
docker-build:
|
variables:
|
||||||
# Use the official docker image.
|
GIT_DEPTH: 0
|
||||||
image: docker:latest
|
|
||||||
stage: build
|
deploy:
|
||||||
services:
|
stage: deploy
|
||||||
- docker:dind
|
only:
|
||||||
before_script:
|
- main
|
||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
variables:
|
||||||
# Default branch leaves tag empty (= latest tag)
|
# specify the `main` branch as the remote branch to push to
|
||||||
# All other branches are tagged with the escaped branch name (commit ref slug)
|
BRANCH: main
|
||||||
script:
|
GIT_REMOTE_URL: ssh://dokku@staging.discours.io:22/discoursio-api
|
||||||
- |
|
script: dokku-deploy
|
||||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
after_script: [dokku-unlock]
|
||||||
tag=""
|
|
||||||
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
|
||||||
else
|
|
||||||
tag=":$CI_COMMIT_REF_SLUG"
|
|
||||||
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
|
||||||
fi
|
|
||||||
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
|
|
||||||
- docker push "$CI_REGISTRY_IMAGE${tag}"
|
|
||||||
# Run this job in a branch where a Dockerfile exists
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_BRANCH
|
|
||||||
exists:
|
|
||||||
- Dockerfile
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user