Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.06 KiB
Newer Older
Simon's avatar
Simon committed
stages:
  - build
  - review
  - production

build:
  stage: build
Simon's avatar
Simon committed
  image:
Simon's avatar
Simon committed
    name: klakegg/hugo:ext-alpine
Simon's avatar
Simon committed
    entrypoint: ['']
Simon's avatar
Simon committed
    - hugo
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - resources/
Simon's avatar
Simon committed
  artifacts:
    paths:
Simon's avatar
Simon committed
    expire_in: 1 hour

review:
  stage: review
  image: instrumentisto/rsync-ssh
Simon's avatar
Simon committed
  before_script:
    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_PRE" | base64 -d | tr -d '\r' | ssh-add -
Simon's avatar
Simon committed
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  script:
    - rsync -av --delete public ffnw.de@ffnw.de:~/pre/$CI_BUILD_REF_SLUG
  environment:
    name: review/$CI_BUILD_REF_NAME
    url: https://$CI_BUILD_REF_SLUG.pre.ffnw.de
    on_stop: stop_review
  only:
    - branches

stop_review:
  stage: review
  image: instrumentisto/rsync-ssh
Simon's avatar
Simon committed
  before_script:
    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_RM" | base64 -d | tr -d '\r' | ssh-add -
Simon's avatar
Simon committed
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  script:
    - ssh ffnw.de@ffnw.de "$CI_BUILD_REF_SLUG"
  variables:
    GIT_STRATEGY: none
  when: manual
  environment:
    name: review/$CI_BUILD_REF_NAME
    action: stop

production:
  stage: production
  image: instrumentisto/rsync-ssh
Simon's avatar
Simon committed
  before_script:
    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_PROD" | base64 -d | tr -d '\r' | ssh-add -
Simon's avatar
Simon committed
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  script:
    - rsync -av --delete public ffnw.de@ffnw.de:~/public
  environment:
    name: production
    url: https://ffnw.de
  when: manual
  only:
    - main