2023-07-30 15:57:37 +02:00
|
|
|
image: rust:latest
|
2023-04-10 14:27:17 +02:00
|
|
|
|
2023-07-30 15:57:37 +02:00
|
|
|
variables:
|
|
|
|
CARGO_TARGET: x86_64-unknown-linux-musl
|
|
|
|
|
|
|
|
before_script:
|
|
|
|
- rustup target add $CARGO_TARGET
|
2023-07-30 16:02:02 +02:00
|
|
|
- apt-get update -qq && apt-get install -y -qq sshpass musl musl-tools
|
2023-07-30 16:10:56 +02:00
|
|
|
- apt update && apt install -y sqlite3 && ./test_db.sh
|
2023-07-30 15:57:37 +02:00
|
|
|
|
|
|
|
build:
|
2023-04-10 14:27:17 +02:00
|
|
|
stage: build
|
2023-07-30 15:57:37 +02:00
|
|
|
script:
|
|
|
|
- cargo build --release --target $CARGO_TARGET
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- target/$CARGO_TARGET/release/rot
|
|
|
|
expire_in: 1 week
|
|
|
|
|
|
|
|
test:
|
|
|
|
stage: test
|
2023-04-10 14:27:17 +02:00
|
|
|
image: rust:latest
|
|
|
|
script:
|
|
|
|
- cargo test --verbose
|
2023-07-30 15:57:37 +02:00
|
|
|
|
2023-07-30 16:46:57 +02:00
|
|
|
deploy-staging:
|
2023-07-30 15:57:37 +02:00
|
|
|
stage: deploy
|
|
|
|
before_script:
|
|
|
|
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
|
|
|
|
- eval $(ssh-agent -s)
|
2023-07-30 16:31:38 +02:00
|
|
|
- echo "$SSH_PRIVATE_KEY" | ssh-add -
|
2023-07-30 15:57:37 +02:00
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- chmod 700 ~/.ssh
|
2023-07-30 16:46:57 +02:00
|
|
|
- ssh-keyscan -H $SSH_HOST > ~/.ssh/known_hosts
|
2023-07-30 15:57:37 +02:00
|
|
|
script:
|
2023-07-30 17:27:32 +02:00
|
|
|
- ssh $SSH_USER@$SSH_HOST 'sudo systemctl stop rotstaging'
|
2023-07-30 15:57:37 +02:00
|
|
|
- scp target/$CARGO_TARGET/release/rot $SSH_USER@$SSH_HOST:/home/k004373/rowing-staging
|
2023-07-30 17:14:56 +02:00
|
|
|
- ssh $SSH_USER@$SSH_HOST 'rm /home/k004373/rowing-staging/db.sqlite && cp /home/k004373/rowing/db.sqlite /home/k004373/rowing-staging/db.sqlite && mkdir /home/k004373/rowing-staging/svelte/build'
|
2023-07-30 16:27:54 +02:00
|
|
|
- scp -r static $SSH_USER@$SSH_HOST:/home/k004373/rowing-staging/
|
|
|
|
- scp -r templates $SSH_USER@$SSH_HOST:/home/k004373/rowing-staging/
|
|
|
|
- scp -r svelte $SSH_USER@$SSH_HOST:/home/k004373/rowing-staging/
|
2023-07-30 17:28:50 +02:00
|
|
|
- ssh $SSH_USER@$SSH_HOST 'sudo systemctl start rotstaging'
|
2023-07-30 15:57:37 +02:00
|
|
|
only:
|
|
|
|
- staging
|
2023-07-30 16:46:57 +02:00
|
|
|
|
|
|
|
deploy-main:
|
|
|
|
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" | ssh-add -
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- chmod 700 ~/.ssh
|
2023-07-30 17:14:56 +02:00
|
|
|
- ssh-keyscan -H $SSH_HOST > ~/.ssh/known_hosts
|
2023-07-30 16:46:57 +02:00
|
|
|
script:
|
2023-07-30 17:27:32 +02:00
|
|
|
- ssh $SSH_USER@$SSH_HOST 'sudo systemctl stop rot'
|
2023-07-30 16:46:57 +02:00
|
|
|
- scp target/$CARGO_TARGET/release/rot $SSH_USER@$SSH_HOST:/home/k004373/rowing
|
2023-07-30 17:30:11 +02:00
|
|
|
- ssh $SSH_USER@$SSH_HOST 'mkdir /home/k004373/rowing-staging/svelte/build'
|
2023-07-30 16:46:57 +02:00
|
|
|
- scp -r static $SSH_USER@$SSH_HOST:/home/k004373/rowing/
|
|
|
|
- scp -r templates $SSH_USER@$SSH_HOST:/home/k004373/rowing/
|
|
|
|
- scp -r svelte $SSH_USER@$SSH_HOST:/home/k004373/rowing/
|
2023-07-30 17:28:50 +02:00
|
|
|
- ssh $SSH_USER@$SSH_HOST 'sudo systemctl start rot'
|
2023-07-30 16:46:57 +02:00
|
|
|
only:
|
|
|
|
- main
|