add ansible script
parent
a123ec71be
commit
7e403d11da
|
@ -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
|
||||
|
|
|
@ -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 }}"
|
Loading…
Reference in New Issue