fix: Apply kubernetes changes to Docker

This commit is contained in:
SPT-dev 2023-03-02 21:12:20 -05:00
parent 1632412945
commit 7017c1652f

View File

@ -8,76 +8,96 @@ concurrency:
trigger: trigger:
event: event:
- push - push
branch:
- master
- main
- development
steps: steps:
- name: replace hosts and user variables - name: replace hosts and user variables
image: ubuntu:impish image: ubuntu:impish
environment: environment:
DEPLOY_HOSTNAME: SPT_ITEMS_HOSTNAME:
from_secret: deploy_hostname from_secret: spt_items_hostname
SPT_ITEMS_HOSTNAME: DEPLOY_HOSTNAME:
from_secret: spt_items_hostname from_secret: deploy_hostname
DEPLOY_USER: DEPLOY_USER:
from_secret: deploy_username from_secret: deploy_username
DEPLOY_SSH_KEY_PASSPHRASE: DEPLOY_PRIVATE_KEY:
from_secret: deploy_ssh_key_passphrase from_secret: deploy_ssh_key
DEPLOY_PRIVATE_KEY: DEPLOY_SSH_KEY_PASSPHRASE:
from_secret: deploy_ssh_key from_secret: deploy_ssh_key_passphrase
commands: commands:
- sed -i 's/{{ SPT_ITEMS_HOSTNAME }}/'"$SPT_ITEMS_HOSTNAME"'/g' ./items/frontend/.env.example - sed -i 's/{{ SPT_ITEMS_HOSTNAME }}/'"$SPT_ITEMS_HOSTNAME"'/g' ./items/frontend/.env.example
- mv ./items/frontend/.env.example ./items/frontend/.env - 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-items/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-items/inventory
- sed -i 's/{{ DEPLOY_USER }}/'"$DEPLOY_USER"'/g' ./.ansible-items/inventory - sed -i 's/{{ DEPLOY_USER }}/'"$DEPLOY_USER"'/g' ./.ansible-items/inventory
- name: build frontend - name: install frontend dependencies
image: node:lts-alpine3.14 image: node:lts-alpine3.14
commands: commands:
- node -v - node -v
- npm -v - npm -v
- yarn --version - yarn --version
- yarn --cwd ./items/frontend install - yarn --cwd ./items/frontend install
- yarn --cwd ./items/frontend build --pure-lockfile - yarn --cwd ./items/frontend build --pure-lockfile
- rm -rf ./items/api/public/static/* - rm -rf ./items/api/public/static/*
- mv ./items/frontend/build/* ./items/api/public - mv ./items/frontend/build/* ./items/api/public
- rm ./items/api/public/index.html - rm ./items/api/public/index.html
- name: check ansible syntax - name: test frontend
image: plugins/ansible:3 image: node:lts-alpine3.14
settings: commands:
playbook: ./.ansible-items/playbook.yml - node -v
inventory: ./.ansible-items/inventory - npm -v
galaxy: ./.ansible-items/requirements.yml - yarn --version
syntax_check: true - yarn --cwd ./items/frontend cy:run
when:
branch:
- development
- name: apply ansible playbook - name: build frontend
image: plugins/ansible:3 image: node:lts-alpine3.14
settings: commands:
playbook: ./.ansible-items/playbook.yml - node -v
inventory: ./.ansible-items/inventory - npm -v
galaxy: ./.ansible-items/requirements.yml - yarn --version
timeout: 60 - yarn --cwd ./items/frontend build --pure-lockfile
verbose: 2 - rm -rf ./items/api/public/static/*
environment: - mv ./items/frontend/build/* ./items/api/public
DEPLOY_HOSTNAME: - rm ./items/api/public/index.html
from_secret: deploy_hostname when:
SPT_ITEMS_HOSTNAME: branch:
from_secret: spt_items_hostname - main
DEPLOY_USER: - master
from_secret: deploy_username - development
DEPLOY_USER_GROUP:
from_secret: deploy_user_group - name: check ansible syntax
SPT_ITEMS_PATH: image: plugins/ansible:3
from_secret: deploy_path settings:
when: playbook: ./.ansible-items/playbook.yml
branch: inventory: ./.ansible-items/inventory
- master galaxy: ./.ansible-items/requirements.yml
- main syntax_check: true
when:
branch:
- development
- name: apply ansible playbook
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:
from_secret: deploy_path
when:
branch:
- master
- main