add ansible script

master
BuckarooBanzay 2021-12-02 07:50:29 +01:00
parent a123ec71be
commit 7e403d11da
3 changed files with 42 additions and 15 deletions

View File

@ -1,28 +1,25 @@
name: deployment
name: deploy
on:
repository_dispatch:
types: [update_deployment]
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: update compose deployment
- name: Prepare environment
run: |
# validate config
docker-compose config -q
# set up ssh
id
eval $(ssh-agent -s)
echo "${{ secrets.SSH_PRIVATE_KEY }}" | tr -d '\r' | ssh-add -
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
ssh-keyscan pandorabox.io >> ~/.ssh/known_hosts
# execute deployment script
cat scripts/deploy.sh | ssh root@pandorabox.io "cd /data/pandorabox.io && /bin/bash -"
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan akheron.rudin.io >> ~/.ssh/known_hosts
chmod -R 700 ~/.ssh
ansible-galaxy collection install community.general
- name: Run ansible
run: |
ansible-playbook -i hosts --private-key ~/.ssh/id_rsa deploy.yml

29
deploy.yml Normal file
View File

@ -0,0 +1,29 @@
---
- hosts: all
remote_user: root
vars:
compose_directory: /data/pandorabox.io
tasks:
- name: Checkout git master
ansible.builtin.git:
repo: https://github.com/pandorabox-io/pandorabox.io
dest: "{{ compose_directory }}"
single_branch: yes
version: master
- name: Generate minetest config
shell:
cmd: "cat minetest.conf minetest.conf.keys > data/minetest/minetest.conf"
chdir: "{{ compose_directory }}"
- name: Create and start services
community.general.docker_compose:
project_src: "{{ compose_directory }}"
pull: yes
build: yes
remove_orphans: yes
- name: Reload nginx config
shell:
cmd: "docker-compose exec -T nginx nginx -s reload"
chdir: "{{ compose_directory }}"

1
hosts Normal file
View File

@ -0,0 +1 @@
akheron.rudin.io