2023-03-02 21:11:58 -05:00
|
|
|
kind: pipeline
|
2023-03-02 21:12:02 -05:00
|
|
|
type: docker
|
2023-03-02 21:13:25 -05:00
|
|
|
name: db deployment
|
2023-03-02 21:11:58 -05:00
|
|
|
|
|
|
|
trigger:
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
|
|
|
steps:
|
2023-03-02 21:12:20 -05:00
|
|
|
- name: replace hosts and user variables
|
|
|
|
image: ubuntu:impish
|
|
|
|
environment:
|
|
|
|
SPT_ITEMS_HOSTNAME:
|
|
|
|
from_secret: spt_items_hostname
|
|
|
|
DEPLOY_HOSTNAME:
|
|
|
|
from_secret: deploy_hostname
|
|
|
|
DEPLOY_USER:
|
|
|
|
from_secret: deploy_username
|
|
|
|
DEPLOY_PRIVATE_KEY:
|
|
|
|
from_secret: deploy_ssh_key
|
|
|
|
DEPLOY_SSH_KEY_PASSPHRASE:
|
|
|
|
from_secret: deploy_ssh_key_passphrase
|
|
|
|
commands:
|
|
|
|
- sed -i 's/{{ SPT_ITEMS_HOSTNAME }}/'"$SPT_ITEMS_HOSTNAME"'/g' ./items/frontend/.env.example
|
|
|
|
- mv ./items/frontend/.env.example ./items/frontend/.env
|
|
|
|
- echo "$DEPLOY_PRIVATE_KEY" > private.key && chmod 600 private.key
|
|
|
|
- sed -i 's/{{ DEPLOY_HOSTNAME }}/'"$DEPLOY_HOSTNAME"'/g' ./.ansible-items/inventory
|
|
|
|
- sed -i 's/{{ DEPLOY_SSH_KEY_PASSPHRASE }}/'"$DEPLOY_SSH_KEY_PASSPHRASE"'/g' ./.ansible-items/inventory
|
|
|
|
- sed -i 's/{{ DEPLOY_USER }}/'"$DEPLOY_USER"'/g' ./.ansible-items/inventory
|
2023-03-02 21:11:58 -05:00
|
|
|
|
2023-03-02 21:12:48 -05:00
|
|
|
- name: install dependencies and build frontend
|
2023-03-02 21:12:20 -05:00
|
|
|
image: node:lts-alpine3.14
|
|
|
|
commands:
|
|
|
|
- node -v
|
|
|
|
- npm -v
|
|
|
|
- yarn --version
|
|
|
|
- yarn --cwd ./items/frontend install
|
2023-03-02 21:12:48 -05:00
|
|
|
- yarn --cwd ./items/frontend build --pure-lockfile
|
|
|
|
- rm -rf ./items/api/public/static/*
|
2023-03-02 21:13:02 -05:00
|
|
|
- cp -r ./items/frontend/build/* ./items/api/public
|
2023-03-02 21:12:48 -05:00
|
|
|
- rm ./items/api/public/index.html
|
2023-03-02 21:12:28 -05:00
|
|
|
depends_on:
|
|
|
|
- replace hosts and user variables
|
|
|
|
|
|
|
|
- name: frontend
|
2023-03-02 21:12:48 -05:00
|
|
|
image: nginx:1.21.4-alpine
|
2023-03-02 21:12:28 -05:00
|
|
|
commands:
|
2023-03-02 21:13:02 -05:00
|
|
|
- cp -r ./items/frontend/build/* /usr/share/nginx/html
|
|
|
|
- cp ./items/frontend/src/cypress/nginx_config/default.conf /etc/nginx/conf.d/default.conf
|
|
|
|
- nginx -g "daemon off;"
|
2023-03-02 21:12:28 -05:00
|
|
|
detach: true
|
|
|
|
depends_on:
|
2023-03-02 21:12:48 -05:00
|
|
|
- install dependencies and build frontend
|
2023-03-02 21:11:58 -05:00
|
|
|
|
2023-03-02 21:12:20 -05:00
|
|
|
- name: test frontend
|
2023-03-02 21:12:32 -05:00
|
|
|
image: cypress/browsers:node16.5.0-chrome94-ff93
|
2023-03-02 21:12:20 -05:00
|
|
|
commands:
|
|
|
|
- node -v
|
|
|
|
- npm -v
|
|
|
|
- yarn --version
|
2023-03-02 21:13:02 -05:00
|
|
|
- yarn --cwd ./items/frontend cy:ci
|
2023-03-02 21:12:28 -05:00
|
|
|
depends_on:
|
2023-03-02 21:12:48 -05:00
|
|
|
- install dependencies and build frontend
|
2023-03-02 21:12:20 -05:00
|
|
|
|
2023-03-02 21:13:22 -05:00
|
|
|
- name: check db ansible syntax
|
2023-03-02 21:12:20 -05:00
|
|
|
image: plugins/ansible:3
|
|
|
|
settings:
|
|
|
|
playbook: ./.ansible-items/playbook.yml
|
|
|
|
inventory: ./.ansible-items/inventory
|
|
|
|
galaxy: ./.ansible-items/requirements.yml
|
|
|
|
syntax_check: true
|
2023-03-02 21:13:22 -05:00
|
|
|
depends_on:
|
|
|
|
- clone
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- development
|
|
|
|
|
|
|
|
- name: apply ansible playbook for items database
|
2023-03-02 21:12:20 -05:00
|
|
|
image: plugins/ansible:3
|
|
|
|
settings:
|
|
|
|
playbook: ./.ansible-items/playbook.yml
|
|
|
|
inventory: ./.ansible-items/inventory
|
|
|
|
galaxy: ./.ansible-items/requirements.yml
|
|
|
|
timeout: 60
|
|
|
|
verbose: 2
|
|
|
|
environment:
|
|
|
|
SPT_ITEMS_HOSTNAME:
|
|
|
|
from_secret: spt_items_hostname
|
|
|
|
DEPLOY_HOSTNAME:
|
|
|
|
from_secret: deploy_hostname
|
|
|
|
DEPLOY_USER:
|
|
|
|
from_secret: deploy_username
|
|
|
|
DEPLOY_USER_GROUP:
|
|
|
|
from_secret: deploy_user_group
|
|
|
|
SPT_ITEMS_PATH:
|
2023-03-02 21:13:30 -05:00
|
|
|
from_secret: db_deploy_path
|
2023-03-02 21:12:28 -05:00
|
|
|
depends_on:
|
2023-03-02 21:12:48 -05:00
|
|
|
- test frontend
|
2023-03-02 21:12:20 -05:00
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
2023-03-02 21:13:22 -05:00
|
|
|
- main
|
|
|
|
event:
|
|
|
|
- promote
|
|
|
|
target:
|
|
|
|
- db
|
|
|
|
|
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
2023-03-02 21:13:25 -05:00
|
|
|
name: website deployment
|
2023-03-02 21:13:22 -05:00
|
|
|
|
|
|
|
trigger:
|
|
|
|
event:
|
|
|
|
- promote
|
|
|
|
branch:
|
2023-03-02 21:13:23 -05:00
|
|
|
- development
|
2023-03-02 21:13:22 -05:00
|
|
|
- main
|
2023-03-02 21:13:23 -05:00
|
|
|
- master
|
2023-03-02 21:13:22 -05:00
|
|
|
|
|
|
|
steps:
|
2023-03-02 21:13:35 -05:00
|
|
|
- name: replace hosts and user variables
|
|
|
|
image: ubuntu:impish
|
|
|
|
environment:
|
|
|
|
DEPLOY_HOSTNAME:
|
|
|
|
from_secret: deploy_hostname
|
|
|
|
DEPLOY_USER:
|
|
|
|
from_secret: deploy_username
|
|
|
|
DEPLOY_PRIVATE_KEY:
|
|
|
|
from_secret: deploy_ssh_key
|
|
|
|
DEPLOY_SSH_KEY_PASSPHRASE:
|
|
|
|
from_secret: deploy_ssh_key_passphrase
|
|
|
|
commands:
|
|
|
|
- echo "$DEPLOY_PRIVATE_KEY" > private.key && chmod 600 private.key
|
|
|
|
- sed -i 's/{{ DEPLOY_HOSTNAME }}/'"$DEPLOY_HOSTNAME"'/g' ./.ansible-website/inventory
|
|
|
|
- sed -i 's/{{ DEPLOY_SSH_KEY_PASSPHRASE }}/'"$DEPLOY_SSH_KEY_PASSPHRASE"'/g' ./.ansible-website/inventory
|
|
|
|
- sed -i 's/{{ DEPLOY_USER }}/'"$DEPLOY_USER"'/g' ./.ansible-website/inventory
|
|
|
|
|
2023-03-02 21:13:22 -05:00
|
|
|
- name: check website ansible syntax
|
|
|
|
image: plugins/ansible:3
|
|
|
|
settings:
|
|
|
|
playbook: ./.ansible-website/playbook.yml
|
|
|
|
inventory: ./.ansible-website/inventory
|
|
|
|
galaxy: ./.ansible-website/requirements.yml
|
|
|
|
syntax_check: true
|
2023-03-02 21:13:23 -05:00
|
|
|
branch:
|
|
|
|
- development
|
2023-03-02 21:13:32 -05:00
|
|
|
- main
|
|
|
|
- master
|
2023-03-02 21:13:22 -05:00
|
|
|
target:
|
|
|
|
- website
|
|
|
|
|
2023-03-02 21:13:27 -05:00
|
|
|
- name: check ansible playbook website
|
2023-03-02 21:13:22 -05:00
|
|
|
image: plugins/ansible:3
|
|
|
|
settings:
|
|
|
|
playbook: ./.ansible-website/playbook.yml
|
|
|
|
inventory: ./.ansible-website/inventory
|
|
|
|
galaxy: ./.ansible-website/requirements.yml
|
|
|
|
timeout: 60
|
|
|
|
verbose: 2
|
|
|
|
check: true
|
|
|
|
environment:
|
|
|
|
DEPLOY_HOSTNAME:
|
|
|
|
from_secret: deploy_hostname
|
|
|
|
DEPLOY_USER:
|
|
|
|
from_secret: deploy_username
|
|
|
|
DEPLOY_USER_GROUP:
|
|
|
|
from_secret: deploy_user_group
|
|
|
|
SPT_WEBSITE_PATH:
|
|
|
|
from_secret: website_deploy_path
|
2023-03-02 21:13:23 -05:00
|
|
|
branch:
|
|
|
|
- development
|
2023-03-02 21:13:22 -05:00
|
|
|
target:
|
2023-03-02 21:13:32 -05:00
|
|
|
- website
|
2023-03-02 21:13:22 -05:00
|
|
|
|
|
|
|
- name: apply ansible playbook website
|
|
|
|
image: plugins/ansible:3
|
|
|
|
settings:
|
|
|
|
playbook: ./.ansible-website/playbook.yml
|
|
|
|
inventory: ./.ansible-website/inventory
|
|
|
|
galaxy: ./.ansible-website/requirements.yml
|
|
|
|
timeout: 60
|
|
|
|
verbose: 2
|
|
|
|
environment:
|
|
|
|
DEPLOY_HOSTNAME:
|
|
|
|
from_secret: deploy_hostname
|
|
|
|
DEPLOY_USER:
|
|
|
|
from_secret: deploy_username
|
|
|
|
DEPLOY_USER_GROUP:
|
|
|
|
from_secret: deploy_user_group
|
|
|
|
SPT_WEBSITE_PATH:
|
|
|
|
from_secret: website_deploy_path
|
2023-03-02 21:13:23 -05:00
|
|
|
branch:
|
|
|
|
- main
|
|
|
|
- master
|
2023-03-02 21:13:22 -05:00
|
|
|
target:
|
|
|
|
- website
|