stages:
  - build
  - deploy

image: alpine:latest

build:dev:
  stage: build
  except:
    - release
    - master
    - /^release-.*$/
  script:
    - apk update
    - apk add nodejs nodejs-npm git
    - npm install
    - npm install cli/
    - npm run-script build
  artifacts:
    paths:
      - build/
    expire_in: 1 month

build:release:
  stage: build
  script:
    - echo "$SSH_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa
    - apk update
    - apk add git
    - git remote -v
    - echo git@${CI_SERVER_NAME}:${CI_PROJECT_PATH_SLUG}
    - git remote set-url origin git@${CI_SERVER_NAME}:${CI_PROJECT_PATH_SLUG}
    - git checkout -b release-test
    - git push --set-upstream origin release-test
    - echo 'test' > test.txt
    - git add test.txt
    - git commit -m 'Add test.txt'
    - git push
    - echo "Done"

deploy:dev:
  stage: deploy
  only:
    - develop
  variables:
    GIT_STRATEGY: none
  dependencies: []
  script:
    - apk update
    - apk add curl
    - curl -X POST -F token=$TURNIERE_TUVERO_TOKEN -F ref=develop http://server.local/api/v4/projects/1/trigger/pipeline

stages:
  - build
  - deploy

image: alpine:latest

build:dev:
  stage: build
  except:
    - release
    - master
    - /^release-.*$/
  script:
    - apk update
    - apk add nodejs nodejs-npm git
    - npm install
    - npm install cli/
    - npm run-script build
  artifacts:
    paths:
      - build/
    expire_in: 1 month

build:release:
  stage: build
  script:
    - mkdir -p ~/.ssh/
    - chmod 700 ~/.ssh/
    - echo "$SSH_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa
    - apk update
    - apk add git
    - git remote -v
    - echo git@${CI_SERVER_NAME}:${CI_PROJECT_PATH_SLUG}
    - git remote set-url origin git@${CI_SERVER_NAME}:${CI_PROJECT_PATH_SLUG}
    - git checkout -b release-test
    - git push --set-upstream origin release-test
    - echo 'test' > test.txt
    - git add test.txt
    - git commit -m 'Add test.txt'
    - git push
    - echo "Done"

deploy:dev:
  stage: deploy
  only:
    - develop
  variables:
    GIT_STRATEGY: none
  dependencies: []
  script:
    - apk update
    - apk add curl
    - curl -X POST -F token=$TURNIERE_TUVERO_TOKEN -F ref=develop http://server.local/api/v4/projects/1/trigger/pipeline

Create .ssh directory during build
Create .ssh directory during build
