fgo-ta-com-website/.gitlab-ci.yml

85 lines
2.3 KiB
YAML
Raw Normal View History

2023-07-17 21:34:53 +00:00
stages:
- validate
- build
- deploy
- scripts
.ssh_default: &ssh_default
- 'which rsync || ( apk update && apk add rsync )'
- 'which ssh-agent || ( apk update && apk add openssh-client)'
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' >> ~/.ssh/key_firq
- chmod 600 ~/.ssh/key_firq
- echo "Host $DEPLOY_HOST" >> ~/.ssh/config
- echo $'\n\tIdentityFile ~/.ssh/key_firq' >> ~/.ssh/config
- echo $'\n\tStrictHostKeyChecking no\n\tIdentitiesOnly yes\n' >> ~/.ssh/config
- chmod 644 ~/.ssh/config
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- echo "SSH setup completed"
checking:
image: node:lts
stage: validate
before_script:
- npm install
script:
- echo "Running Astro checks"
- npm run astro check
build-site:
image: node:lts
stage: build
when: on_success
cache:
paths:
- node_modules/
script:
- npm install
- npm run build
- rm -r public/assets/data/
- cp serve.json public
artifacts:
paths:
- public
expire_in: 1 day
deploy-site:
stage: deploy
when: on_success
only:
- tags
except:
- branches
before_script:
- *ssh_default
script:
- echo "Getting artifacts"
- ls public
- echo "Stopping screen session, cleaning"
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S fgo-ta_com-public kill; rm -r -f fgo-ta_com/public/*;"
2023-07-17 21:34:53 +00:00
- echo "Copying to proxmox machine"
- rsync -az --stats public/* $DEPLOY_USER@$DEPLOY_HOST:~/fgo-ta_com/public
2023-07-17 21:34:53 +00:00
- echo "Restarting screen session"
2023-08-04 20:29:38 +00:00
- ssh $DEPLOY_USER@$DEPLOY_HOST 'PATH="$HOME/.local/bin:$PATH"; cd fgo-ta_com; find public -maxdepth 1 -printf "%p\n"; screen -S fgo-ta_com-public -dm serve public/ -p 9200'
2023-07-17 21:34:53 +00:00
- echo "Website is up on https://fgo-ta.com"
redeploy-site:
stage: scripts
when: manual
only:
- tags
except:
- branches
before_script:
- *ssh_default
script:
- echo "Stopping screen session"
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S website-fgota-npx kill" || true
- echo "Restarting screen session"
2023-08-04 20:29:38 +00:00
- ssh $DEPLOY_USER@$DEPLOY_HOST 'PATH="$HOME/.local/bin:$PATH"; cd fgo-ta_com; screen -S fgo-ta_com-public -dm serve public/ -p 9200'
2023-07-17 21:34:53 +00:00
- echo "Website is up on https://fgo-ta.com/"