Skip to content
.gitlab-ci.yml 1.05 KiB
Newer Older
nimrod's avatar
nimrod committed
---
include:
  - project: shore/ci-templates
    file: templates/pre-commit.yml

variables:
  TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/default

stages:
  - test
  - build
  - plan
  - apply

Generate payload:
  stage: build
  image: registry.shore.co.il/ci-images:python3
  variables:
    XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache"
  before_script:
    - apt-get update
    - apt-get install -y zip
  script:
    make payload.zip
  artifacts:
    paths:
      - payload.zip
  cache:
    paths:
      - .cache/

Terraform plan:
  stage: plan
  image: &tf_image registry.gitlab.com/gitlab-org/terraform-images/stable:latest
  script:
    - gitlab-terraform plan
    - gitlab-terraform plan-json
  dependencies:
    - Generate payload
  artifacts:
    name: plan
    paths:
      - plan.cache
    reports:
      terraform: plan.json

Terraform apply:
  stage: apply
  image: *tf_image
  script:
    - gitlab-terraform apply
  dependencies: &tf_apply_dependecies
    - Generate payload
    - Terraform plan
  when: manual
  needs: *tf_apply_dependecies