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-09-05 13:41:11 +02:00
|
|
|
- apt-get update -qq && apt-get install -y -qq sshpass musl musl-tools sqlite3 curl gnupg && mkdir -p /etc/apt/keyrings | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && apt-get update && apt-get install nodejs -y && apt-get install npm -y
|
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-09-05 13:54:03 +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-08-02 15:02:03 +02:00
|
|
|
- scp staging-diff.sql $SSH_USER@$SSH_HOST:/home/k004373/rowing-staging/
|
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'
|
2023-11-02 13:01:19 +01: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 -p /home/k004373/rowing-staging/svelte/build && mkdir -p /home/k004373/rowing-staging/data-ergo/thirty && mkdir -p /home/k004373/rowing-staging/data-ergo/dozen && sqlite3 /home/k004373/rowing-staging/db.sqlite < /home/k004373/rowing-staging/staging-diff.sql'
|
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-11-02 12:15:10 +01:00
|
|
|
- ssh $SSH_USER@$SSH_HOST 'mkdir -p /home/k004373/rowing/svelte/build && mkdir -p /home/k004373/rowing-staging/data-ergo/thirty && mkdir -p /home/k004373/rowing-staging/data-ergo/dozen'
|
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
|