rowt/.gitlab-ci.yml

70 lines
2.6 KiB
YAML
Raw Normal View History

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 19:37:08 +02:00
- apt-get update -qq && apt-get install -y -qq sshpass musl musl-tools sqlite3 curl gnupg && curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
2023-07-30 19:35:10 +02:00
- ./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
2023-08-01 14:53:06 +02:00
- strip target/$CARGO_TARGET/release/rot
2023-07-30 19:20:04 +02:00
- cd frontend && npm install && npm run build
2023-07-30 15:57:37 +02:00
artifacts:
paths:
- target/$CARGO_TARGET/release/rot
2023-07-30 22:35:17 +02:00
- static
2023-07-30 15:57:37 +02:00
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:56:32 +02:00
- scp target/$CARGO_TARGET/release/rot $SSH_USER@$SSH_HOST:/home/k004373/rowing-staging/rot-updating
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:56:32 +02:00
- ssh $SSH_USER@$SSH_HOST 'sudo systemctl stop rotstaging'
- 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 -p /home/k004373/rowing-staging/svelte/build'
2023-07-30 18:30:56 +02:00
- ssh $SSH_USER@$SSH_HOST 'mv /home/k004373/rowing-staging/rot-updating /home/k004373/rowing-staging/rot'
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:56:32 +02:00
- scp target/$CARGO_TARGET/release/rot $SSH_USER@$SSH_HOST:/home/k004373/rowing/rot-updating
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:56:32 +02:00
- ssh $SSH_USER@$SSH_HOST 'mkdir -p /home/k004373/rowing/svelte/build'
2023-07-30 18:30:56 +02:00
- ssh $SSH_USER@$SSH_HOST 'sudo systemctl stop rot'
- ssh $SSH_USER@$SSH_HOST 'mv /home/k004373/rowing/rot-updating /home/k004373/rowing/rot'
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