From 91d15f162f712858951221e8f31943fd897e4f85 Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 30 Jul 2023 15:57:37 +0200 Subject: [PATCH] first draft of ci deploy --- .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d98e2fd..9c26584 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,38 @@ -stages: - - build +image: rust:latest -rust-latest: +variables: + CARGO_TARGET: x86_64-unknown-linux-musl + +before_script: + - rustup target add $CARGO_TARGET + - apt-get update -qq && apt-get install -y -qq sshpass + +build: stage: build + script: + - cargo build --release --target $CARGO_TARGET + artifacts: + paths: + - target/$CARGO_TARGET/release/rot + expire_in: 1 week + +test: + stage: test image: rust:latest script: - apt update && apt install -y sqlite3 && ./test_db.sh - cargo build --verbose - cargo test --verbose + +deploy: + stage: deploy + before_script: + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + script: + - scp target/$CARGO_TARGET/release/rot $SSH_USER@$SSH_HOST:/home/k004373/rowing-staging + only: + - staging