feat: add automatic website deployment

This commit is contained in:
Mangiang 2022-05-06 21:49:53 -04:00
parent f23acb81a8
commit 63f325c616
4 changed files with 111 additions and 7 deletions

View File

@ -0,0 +1,11 @@
all:
children:
sptarkov:
hosts:
sp-tarkov:
ansible_host: {{ DEPLOY_HOSTNAME }}
ansible_user: {{ DEPLOY_USER }}
ansible_connection: paramiko_ssh
ansible_ssh_pass: {{ DEPLOY_SSH_KEY_PASSPHRASE }}
ansible_ssh_user: {{ DEPLOY_USER }}
ansible_ssh_private_key_file: /drone/src/private.key # Hardcoded because created by the Drone plugin

View File

@ -0,0 +1,11 @@
---
- name: update the server
hosts: sptarkov
tasks:
- name: Update website
git:
repo: "{{ lookup('env', 'DRONE_REPO_LINK') }}"
dest: "{{ lookup('env', 'SPT_WEBSITE_PATH') }}"
update: yes
version: master

View File

@ -0,0 +1,2 @@
collections:
- name: community.general # For composer

View File

@ -2,9 +2,6 @@ kind: pipeline
type: docker type: docker
name: default name: default
concurrency:
limit: 1
trigger: trigger:
event: event:
- push - push
@ -65,18 +62,33 @@ steps:
depends_on: depends_on:
- install dependencies and build frontend - install dependencies and build frontend
- name: check ansible syntax - name: check db ansible syntax
image: plugins/ansible:3 image: plugins/ansible:3
settings: settings:
playbook: ./.ansible-items/playbook.yml playbook: ./.ansible-items/playbook.yml
inventory: ./.ansible-items/inventory inventory: ./.ansible-items/inventory
galaxy: ./.ansible-items/requirements.yml galaxy: ./.ansible-items/requirements.yml
syntax_check: true syntax_check: true
depends_on:
- clone
when: when:
branch: branch:
- development - development
- name: apply ansible playbook - name: check website ansible syntax for items database
image: plugins/ansible:3
settings:
playbook: ./.ansible-items/playbook.yml
inventory: ./.ansible-items/inventory
galaxy: ./.ansible-items/requirements.yml
syntax_check: true
depends_on:
- clone
when:
branch:
- development
- name: apply ansible playbook for items database
image: plugins/ansible:3 image: plugins/ansible:3
settings: settings:
playbook: ./.ansible-items/playbook.yml playbook: ./.ansible-items/playbook.yml
@ -94,10 +106,78 @@ steps:
DEPLOY_USER_GROUP: DEPLOY_USER_GROUP:
from_secret: deploy_user_group from_secret: deploy_user_group
SPT_ITEMS_PATH: SPT_ITEMS_PATH:
from_secret: deploy_path from_secret: items_deploy_path
depends_on: depends_on:
- test frontend - test frontend
when: when:
branch: branch:
- master - master
- main - main
event:
- promote
target:
- db
---
kind: pipeline
type: docker
name: default
trigger:
event:
- promote
branch:
- main
steps:
- 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
target:
- website-check
- website
- 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
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
target:
- website-check
- 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
target:
- website