Commit f97a3cb6 authored by Neil Moore's avatar Neil Moore
Browse files

[CI/CD] Add production build & deploy jobs

parent 0165fb4a
stages:
- build
- deploy-staging
- deploy-production
build-drafts:
stage: build
......@@ -12,6 +13,20 @@ build-drafts:
paths:
- build/
build-production:
stage: build
image: registry.gitlab.com/dar13/moor3-website-hugo/build:latest
script:
- hugo -d build
allow_failure: false
artifacts:
when: on_success
paths:
- build/
only:
refs:
- main
deploy-to-staging:
stage: deploy-staging
image: ubuntu
......@@ -31,7 +46,31 @@ deploy-to-staging:
name: moor3-staging
url: staging.$WEBSITE_URL
allow_failure: false
when: on_success
when: manual
only:
refs:
- main
deploy-to-production:
stage: deploy-production
image: ubuntu
needs: ["build-production"]
# Move this into a common thing, shared with other deploy jobs
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh $WEBSITE_USER@$WEBSITE_URL rm -rf /home/nmoore/websites/$CI_ENVIRONMENT_NAME/*
- scp -r ./build/* $WEBSITE_USER@$WEBSITE_URL:/home/nmoore/websites/$CI_ENVIRONMENT_NAME/
environment:
name: moor3
url: $WEBSITE_URL
allow_failure: false
when: manual
only:
refs:
- main
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment