first shot on a gitlab-ci file
This commit is contained in:
parent
e25441f548
commit
8e35e9300e
1 changed files with 47 additions and 0 deletions
47
.gitlab-ci.yml
Normal file
47
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
variables:
|
||||
DOCKER_TLS_CERTDIR: "/certs"
|
||||
CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA"
|
||||
RAILS_ENV: "production"
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- docker build -t $CONTAINER_IMAGE .
|
||||
- docker push $CONTAINER_IMAGE
|
||||
only:
|
||||
- main
|
||||
- merge_requests
|
||||
|
||||
test:
|
||||
stage: test
|
||||
services:
|
||||
- postgres:latest
|
||||
variables:
|
||||
POSTGRES_DB: "rails_test"
|
||||
POSTGRES_USER: "postgres"
|
||||
POSTGRES_PASSWORD: "password"
|
||||
DATABASE_URL: "postgresql://postgres:password@postgres:5432/rails_test"
|
||||
script:
|
||||
- docker run --rm $CONTAINER_IMAGE bin/rails db:create db:migrate RAILS_ENV=test
|
||||
- docker run --rm $CONTAINER_IMAGE bin/rails test
|
||||
only:
|
||||
- main
|
||||
- merge_requests
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
script:
|
||||
- echo "Deploying to production..."
|
||||
# Add your deployment commands here
|
||||
# For example, if using Kubernetes:
|
||||
# - kubectl set image deployment/rails-app rails-app=$CONTAINER_IMAGE
|
||||
only:
|
||||
- main
|
||||
Loading…
Add table
Add a link
Reference in a new issue