65 lines
2.0 KiB
YAML
65 lines
2.0 KiB
YAML
# define the stages in this pipeline
|
|
stages:
|
|
- build
|
|
- deploy
|
|
|
|
# define the build stage
|
|
|
|
build_stage:
|
|
stage: build
|
|
# use node docker image as enviroment
|
|
image: oven/bun:canary-debian
|
|
script:
|
|
# install & build the NuxtJS application
|
|
- apt update && apt-get install -y --no-install-recommends python3
|
|
- bun install
|
|
- sed -Ei "s,(hasMigrated = )false,\1true," ${CI_PROJECT_DIR}/lib/dbconfig.ts
|
|
- NODE_ENV=production bun run --bun build
|
|
# define artifacts which are shared between stages
|
|
artifacts:
|
|
paths:
|
|
- .output/
|
|
- .nuxt/
|
|
|
|
# define the deploy stages
|
|
deploy_staging:
|
|
stage: deploy
|
|
resource_group: staging
|
|
needs:
|
|
- build_stage
|
|
environment:
|
|
name: staging
|
|
url: https://next.rockfic.com
|
|
image: ubuntu:latest
|
|
before_script:
|
|
- ". ${CI_PROJECT_DIR}/.more-ci/deploy-pre.sh ${SSH_DEPLOY_KEY}"
|
|
script:
|
|
- rsync --archive ${CI_PROJECT_DIR}/ rockfic@${DEPLOY_SERVER}:~/rockfic-staging/
|
|
- scp ${ENV_FILE} rockfic@${DEPLOY_SERVER}:rockfic-staging/.env
|
|
- sshpass -p "${OLDROOTPWD}" ssh root@rockfic.com '~/cp.sh'
|
|
- ssh rockfic@${DEPLOY_SERVER} "~/stage.sh" ${DB_NAME}
|
|
# restart Node.js and reload nginx configuration
|
|
- ssh rockfic@${DEPLOY_SERVER} 'NODE_ENV=production nohup bun run --bun "~/rockfic-staging/.output/server/index.mjs" & disown %1'
|
|
- ssh rockfic@${DEPLOY_SERVER} sudo systemctl reload apache2
|
|
except:
|
|
- tags
|
|
deploy_production:
|
|
stage: deploy
|
|
needs:
|
|
- build_stage
|
|
resource_group: production
|
|
environment:
|
|
name: production
|
|
url: https://www.rockfic.com
|
|
image: ubuntu:latest
|
|
before_script:
|
|
- ". ${CI_PROJECT_DIR}/.more-ci/deploy-pre.sh ${SSH_DEPLOY_KEY}"
|
|
script:
|
|
- rsync --archive ${CI_PROJECT_DIR}/ root@${DEPLOY_SERVER}:/home/@rockfic/
|
|
- scp ${ENV_FILE} root@${DEPLOY_SERVER}:/home/@rockfic/.env
|
|
- ssh root@${DEPLOY_SERVER} 'nohup bun "/home/@rockfic/.output/server/index.mjs" & disown %1'
|
|
- ssh root@${DEPLOY_SERVER} sudo systemctl reload apache2
|
|
only:
|
|
- tags
|
|
# restrict to specific branch
|