fix: drone pipeline for kubernetes
This commit is contained in:
parent
84f9011a70
commit
cfbfca3358
@ -1,20 +1,16 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: kubernetes
|
type: docker
|
||||||
name: default
|
name: website deployment
|
||||||
|
|
||||||
concurrency:
|
|
||||||
limit: 1
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: replace hosts and user variables
|
- name: replace hosts and user variables
|
||||||
image: ubuntu:impish
|
image: ubuntu:impish
|
||||||
environment:
|
environment:
|
||||||
SPT_ITEMS_HOSTNAME:
|
|
||||||
from_secret: spt_items_hostname
|
|
||||||
DEPLOY_HOSTNAME:
|
DEPLOY_HOSTNAME:
|
||||||
from_secret: deploy_hostname
|
from_secret: deploy_hostname
|
||||||
DEPLOY_USER:
|
DEPLOY_USER:
|
||||||
@ -24,80 +20,88 @@ steps:
|
|||||||
DEPLOY_SSH_KEY_PASSPHRASE:
|
DEPLOY_SSH_KEY_PASSPHRASE:
|
||||||
from_secret: deploy_ssh_key_passphrase
|
from_secret: deploy_ssh_key_passphrase
|
||||||
commands:
|
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
|
- 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_HOSTNAME }}/'"$DEPLOY_HOSTNAME"'/g' ./.ansible/inventory
|
||||||
- sed -i 's/{{ DEPLOY_SSH_KEY_PASSPHRASE }}/'"$DEPLOY_SSH_KEY_PASSPHRASE"'/g' ./.ansible-items/inventory
|
- sed -i 's/{{ DEPLOY_SSH_KEY_PASSPHRASE }}/'"$DEPLOY_SSH_KEY_PASSPHRASE"'/g' ./.ansible/inventory
|
||||||
- sed -i 's/{{ DEPLOY_USER }}/'"$DEPLOY_USER"'/g' ./.ansible-items/inventory
|
- sed -i 's/{{ DEPLOY_USER }}/'"$DEPLOY_USER"'/g' ./.ansible/inventory
|
||||||
|
|
||||||
- name: install dependencies and build frontend
|
|
||||||
image: node:lts-alpine3.14
|
|
||||||
commands:
|
|
||||||
- node -v
|
|
||||||
- npm -v
|
|
||||||
- yarn --version
|
|
||||||
- yarn --cwd ./items/frontend install
|
|
||||||
- yarn --cwd ./items/frontend build --pure-lockfile
|
|
||||||
- rm -rf ./items/api/public/static/*
|
|
||||||
- cp -r ./items/frontend/build/* ./items/api/public
|
|
||||||
- rm ./items/api/public/index.html
|
|
||||||
depends_on:
|
|
||||||
- replace hosts and user variables
|
|
||||||
|
|
||||||
- name: frontend
|
|
||||||
image: nginx:1.21.4-alpine
|
|
||||||
commands:
|
|
||||||
- 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;"
|
|
||||||
detach: true
|
|
||||||
depends_on:
|
|
||||||
- install dependencies and build frontend
|
|
||||||
|
|
||||||
- name: test frontend
|
|
||||||
image: cypress/browsers:node16.5.0-chrome94-ff93
|
|
||||||
commands:
|
|
||||||
- node -v
|
|
||||||
- npm -v
|
|
||||||
- yarn --version
|
|
||||||
- yarn --cwd ./items/frontend cy:ci
|
|
||||||
depends_on:
|
|
||||||
- install dependencies and build frontend
|
|
||||||
|
|
||||||
- name: check ansible syntax
|
|
||||||
image: plugins/ansible:3
|
|
||||||
settings:
|
|
||||||
playbook: ./.ansible-items/playbook.yml
|
|
||||||
inventory: ./.ansible-items/inventory
|
|
||||||
galaxy: ./.ansible-items/requirements.yml
|
|
||||||
syntax_check: true
|
|
||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
|
- master
|
||||||
- development
|
- development
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
- name: apply ansible playbook
|
- name: check website ansible syntax
|
||||||
image: plugins/ansible:3
|
image: plugins/ansible:3
|
||||||
settings:
|
settings:
|
||||||
playbook: ./.ansible-items/playbook.yml
|
playbook: ./.ansible/playbook.yml
|
||||||
inventory: ./.ansible-items/inventory
|
inventory: ./.ansible/inventory
|
||||||
galaxy: ./.ansible-items/requirements.yml
|
syntax_check: true
|
||||||
|
depends_on:
|
||||||
|
- replace hosts and user variables
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
- development
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: dry-run ansible playbook website
|
||||||
|
image: plugins/ansible:3
|
||||||
|
settings:
|
||||||
|
playbook: ./.ansible/playbook.yml
|
||||||
|
inventory: ./.ansible/inventory
|
||||||
timeout: 60
|
timeout: 60
|
||||||
verbose: 2
|
verbose: 2
|
||||||
|
check: true
|
||||||
environment:
|
environment:
|
||||||
SPT_ITEMS_HOSTNAME:
|
|
||||||
from_secret: spt_items_hostname
|
|
||||||
DEPLOY_HOSTNAME:
|
DEPLOY_HOSTNAME:
|
||||||
from_secret: deploy_hostname
|
from_secret: deploy_hostname
|
||||||
DEPLOY_USER:
|
DEPLOY_USER:
|
||||||
from_secret: deploy_username
|
from_secret: deploy_username
|
||||||
DEPLOY_USER_GROUP:
|
DEPLOY_USER_GROUP:
|
||||||
from_secret: deploy_user_group
|
from_secret: deploy_user_group
|
||||||
SPT_ITEMS_PATH:
|
SPT_WEBSITE_PATH:
|
||||||
from_secret: deploy_path
|
from_secret: website_deploy_path
|
||||||
depends_on:
|
depends_on:
|
||||||
- test frontend
|
- check website ansible syntax
|
||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
- main
|
- development
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: apply ansible playbook website
|
||||||
|
image: plugins/ansible:3
|
||||||
|
settings:
|
||||||
|
playbook: ./.ansible/playbook.yml
|
||||||
|
inventory: ./.ansible/inventory
|
||||||
|
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
|
||||||
|
depends_on:
|
||||||
|
- check website ansible syntax
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
Loading…
x
Reference in New Issue
Block a user