2023-03-10 23:51:29 +00:00
|
|
|
stages:
|
2023-03-21 10:39:31 +00:00
|
|
|
- validate
|
2023-03-17 01:01:20 +00:00
|
|
|
- build
|
2023-03-11 00:15:01 +00:00
|
|
|
- deploy
|
2023-07-08 21:07:13 +00:00
|
|
|
- benchmark
|
2023-03-20 20:25:35 +00:00
|
|
|
- post_deploy
|
2023-04-22 16:31:59 +00:00
|
|
|
- scripts
|
2023-03-20 20:25:35 +00:00
|
|
|
|
|
|
|
.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"
|
2023-03-10 23:51:29 +00:00
|
|
|
|
2023-03-21 10:39:31 +00:00
|
|
|
checking:
|
|
|
|
image: node:lts
|
|
|
|
stage: validate
|
|
|
|
before_script:
|
|
|
|
- npm install
|
|
|
|
script:
|
|
|
|
- echo "Running Astro checks"
|
|
|
|
- npm run astro check
|
|
|
|
|
2023-03-17 01:01:20 +00:00
|
|
|
build-site:
|
|
|
|
image: node:lts
|
|
|
|
stage: build
|
2023-03-21 10:39:31 +00:00
|
|
|
when: on_success
|
2023-03-17 01:01:20 +00:00
|
|
|
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
|
|
|
|
|
2023-03-06 18:12:59 +00:00
|
|
|
deploy-site:
|
|
|
|
stage: deploy
|
2023-03-21 10:39:31 +00:00
|
|
|
when: on_success
|
2023-03-17 01:01:20 +00:00
|
|
|
only:
|
2023-07-06 17:45:00 +00:00
|
|
|
- tags
|
|
|
|
except:
|
|
|
|
- branches
|
2023-03-06 18:12:59 +00:00
|
|
|
before_script:
|
2023-03-20 20:25:35 +00:00
|
|
|
- *ssh_default
|
2023-03-10 23:51:29 +00:00
|
|
|
script:
|
2023-03-17 01:01:20 +00:00
|
|
|
- echo "Getting artifacts"
|
|
|
|
- ls public
|
2023-03-20 20:25:35 +00:00
|
|
|
- echo "Stopping screen session, cleaning"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S website-firq-npx kill; rm -r -f firq_dev/public/*;"
|
2023-03-17 01:01:20 +00:00
|
|
|
- echo "Copying to proxmox machine"
|
2023-07-27 20:52:35 +00:00
|
|
|
- rsync -az --stats public/* $DEPLOY_USER@$DEPLOY_HOST:~/firq_dev/public
|
2023-03-17 01:01:20 +00:00
|
|
|
- echo "Restarting screen session"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "cd firq_dev; find maintenance public -maxdepth 1 -printf '%p\n'; screen -S website-firq-npx -dm npx serve public/ -p 9000 -c serve.json"
|
2023-03-17 01:01:20 +00:00
|
|
|
- echo "Website is up on https://firq.dev/"
|
2023-03-06 18:12:59 +00:00
|
|
|
|
2023-07-07 12:17:25 +00:00
|
|
|
deploy-testing:
|
|
|
|
stage: deploy
|
|
|
|
when: on_success
|
|
|
|
except:
|
|
|
|
- tags
|
|
|
|
- main
|
|
|
|
before_script:
|
|
|
|
- *ssh_default
|
|
|
|
script:
|
|
|
|
- echo "Getting artifacts"
|
|
|
|
- ls public
|
|
|
|
- echo "Stopping screen session, cleaning"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S staging-firq-npx kill; rm -r -f firq_dev/staging/*;"
|
2023-07-07 12:17:25 +00:00
|
|
|
- echo "Copying to proxmox machine"
|
2023-07-27 20:52:35 +00:00
|
|
|
- rsync -az --stats public/* $DEPLOY_USER@$DEPLOY_HOST:~/firq_dev/staging
|
2023-07-07 12:17:25 +00:00
|
|
|
- echo "Restarting screen session"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "cd firq_dev; find staging -maxdepth 1 -printf '%p\n'; screen -S staging-firq-npx -dm npx serve staging/ -p 9100 -c serve.json"
|
2023-07-07 12:17:25 +00:00
|
|
|
- echo "Staging environment is up!"
|
|
|
|
|
2023-07-08 21:07:13 +00:00
|
|
|
unlighthouse:
|
|
|
|
image: registry.gitlab.com/gitlab-ci-utils/lighthouse:latest
|
|
|
|
stage: benchmark
|
2023-07-08 22:06:17 +00:00
|
|
|
when: manual
|
2023-07-08 21:07:13 +00:00
|
|
|
except:
|
|
|
|
- main
|
|
|
|
- tags
|
|
|
|
before_script:
|
2023-07-08 21:30:15 +00:00
|
|
|
- npm install @unlighthouse/cli puppeteer
|
2023-07-08 21:07:13 +00:00
|
|
|
- mkdir unlighthouse-reports
|
|
|
|
script:
|
2023-07-08 21:52:47 +00:00
|
|
|
- node_modules/.bin/unlighthouse-ci
|
2023-07-08 21:07:13 +00:00
|
|
|
- cp public/serve.json unlighthouse-reports
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- unlighthouse-reports
|
|
|
|
expire_in: 1 day
|
|
|
|
|
2023-07-08 22:06:17 +00:00
|
|
|
unlighthouse-publish:
|
|
|
|
stage: benchmark
|
2023-07-08 21:07:13 +00:00
|
|
|
when: on_success
|
2023-07-08 22:06:17 +00:00
|
|
|
needs:
|
|
|
|
- unlighthouse
|
2023-07-08 21:07:13 +00:00
|
|
|
except:
|
|
|
|
- tags
|
|
|
|
- main
|
|
|
|
before_script:
|
|
|
|
- *ssh_default
|
|
|
|
script:
|
|
|
|
- echo "Getting artifacts"
|
|
|
|
- ls unlighthouse-reports
|
|
|
|
- echo "Stopping screen session, cleaning"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S unlighthouse-results kill; rm -r -f firq_dev/unlighthouse/*;"
|
2023-07-08 21:07:13 +00:00
|
|
|
- echo "Copying to proxmox machine"
|
2023-07-27 20:52:35 +00:00
|
|
|
- rsync -az --stats unlighthouse-reports/* $DEPLOY_USER@$DEPLOY_HOST:~/firq_dev/unlighthouse
|
2023-07-08 21:07:13 +00:00
|
|
|
- echo "Restarting screen session"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "cd firq_dev; find unlighthouse -maxdepth 1 -printf '%p\n'; screen -S unlighthouse -dm npx serve unlighthouse/ -p 9101 -c serve.json"
|
2023-07-08 22:11:15 +00:00
|
|
|
- echo "Unlighthouse results are up!"
|
2023-07-08 21:07:13 +00:00
|
|
|
|
2023-03-10 23:51:29 +00:00
|
|
|
success_notification:
|
2023-03-20 20:25:35 +00:00
|
|
|
stage: post_deploy
|
2023-03-11 00:04:56 +00:00
|
|
|
before_script:
|
2023-03-11 00:10:19 +00:00
|
|
|
- apk update
|
2023-03-17 01:01:20 +00:00
|
|
|
- apk add rsync
|
2023-03-11 00:10:19 +00:00
|
|
|
- apk add curl
|
|
|
|
- apk add git
|
2023-03-11 00:31:48 +00:00
|
|
|
- apk add bash
|
2023-03-10 23:51:29 +00:00
|
|
|
script:
|
2023-03-11 00:31:48 +00:00
|
|
|
- wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
|
2023-03-10 23:51:29 +00:00
|
|
|
- chmod +x send.sh
|
|
|
|
- ./send.sh success $WEBHOOK_URL
|
|
|
|
when: on_success
|
2023-03-17 17:56:34 +00:00
|
|
|
|
2023-03-10 23:51:29 +00:00
|
|
|
failure_notification:
|
2023-03-20 20:25:35 +00:00
|
|
|
stage: post_deploy
|
2023-03-11 00:04:56 +00:00
|
|
|
before_script:
|
2023-03-11 00:10:19 +00:00
|
|
|
- apk update
|
|
|
|
- apk add curl
|
|
|
|
- apk add git
|
2023-03-11 00:31:48 +00:00
|
|
|
- apk add bash
|
2023-01-21 18:23:34 +00:00
|
|
|
script:
|
2023-03-11 00:31:48 +00:00
|
|
|
- wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
|
2023-03-10 23:51:29 +00:00
|
|
|
- chmod +x send.sh
|
|
|
|
- ./send.sh failure $WEBHOOK_URL
|
|
|
|
when: on_failure
|
2023-03-20 20:25:35 +00:00
|
|
|
|
|
|
|
maintenance-mode:
|
|
|
|
stage: post_deploy
|
|
|
|
when: on_failure
|
|
|
|
before_script:
|
|
|
|
- *ssh_default
|
2023-07-07 12:30:38 +00:00
|
|
|
only:
|
2023-07-08 15:34:14 +00:00
|
|
|
- tags
|
2023-07-07 12:30:38 +00:00
|
|
|
- main
|
2023-03-20 20:25:35 +00:00
|
|
|
script:
|
|
|
|
- echo "Stopping screen session"
|
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S website-firq-npx kill;"
|
|
|
|
- echo "Enabeling maintenance mode"
|
2023-07-27 21:10:36 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -S website-firq-npx -dm npx serve firq_dev/maintenance/ -p 9000 -c serve.json"
|
2023-03-20 20:25:35 +00:00
|
|
|
- echo "Maintenance Website is up on https://firq.dev/"
|
2023-04-22 16:31:59 +00:00
|
|
|
|
|
|
|
redeploy-site:
|
|
|
|
stage: scripts
|
|
|
|
when: manual
|
2023-07-06 17:45:00 +00:00
|
|
|
only:
|
|
|
|
- tags
|
|
|
|
except:
|
|
|
|
- branches
|
2023-04-22 16:51:13 +00:00
|
|
|
before_script:
|
|
|
|
- *ssh_default
|
2023-04-22 16:31:59 +00:00
|
|
|
script:
|
|
|
|
- echo "Stopping screen session"
|
2023-05-01 16:08:58 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S website-firq-npx kill" || true
|
2023-04-22 16:31:59 +00:00
|
|
|
- echo "Restarting screen session"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -S website-firq-npx -dm npx serve firq_dev/public/ -p 9000 -c serve.json"
|
2023-04-22 16:31:59 +00:00
|
|
|
- echo "Website is up on https://firq.dev/"
|
2023-07-08 13:44:10 +00:00
|
|
|
|
|
|
|
redeploy-staging:
|
|
|
|
stage: scripts
|
|
|
|
when: manual
|
|
|
|
except:
|
|
|
|
- main
|
|
|
|
- tags
|
|
|
|
before_script:
|
|
|
|
- *ssh_default
|
|
|
|
script:
|
|
|
|
- echo "Stopping screen session"
|
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S staging-firq-npx kill" || true
|
|
|
|
- echo "Restarting screen session"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -S staging-firq-npx -dm npx serve firq_dev/staging/ -p 9100 -c serve.json"
|
2023-07-08 13:44:10 +00:00
|
|
|
- echo "Staging environment is up!"
|
2023-07-08 15:34:14 +00:00
|
|
|
|
2023-07-08 21:07:13 +00:00
|
|
|
redeploy-unlighthouse:
|
|
|
|
stage: scripts
|
|
|
|
when: manual
|
|
|
|
except:
|
|
|
|
- main
|
|
|
|
- tags
|
|
|
|
before_script:
|
|
|
|
- *ssh_default
|
|
|
|
script:
|
|
|
|
- echo "Stopping screen session"
|
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S unlighthouse-results kill" || true
|
|
|
|
- echo "Restarting screen session"
|
2023-07-27 20:52:35 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -S unlighthouse-results -dm npx serve firq_dev/unlighthouse/ -p 9101 -c serve.json"
|
2023-07-08 21:07:13 +00:00
|
|
|
- echo "Staging environment is up!"
|
|
|
|
|
2023-07-08 15:34:14 +00:00
|
|
|
maintenance-deploy:
|
|
|
|
stage: scripts
|
|
|
|
when: manual
|
|
|
|
only:
|
|
|
|
- main
|
|
|
|
- tags
|
|
|
|
before_script:
|
|
|
|
- *ssh_default
|
|
|
|
script:
|
|
|
|
- echo "Stopping screen session"
|
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S website-firq-npx kill;" || true
|
|
|
|
- echo "Enabeling maintenance mode"
|
2023-07-27 21:10:36 +00:00
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST "screen -S website-firq-npx -dm npx serve firq_dev/maintenance/ -p 9000 -c serve.json"
|
2023-07-08 15:34:14 +00:00
|
|
|
- echo "Maintenance Website is up on https://firq.dev/"
|