From b98d5238901dd35de6478bb35e4068b39dd61b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20Melein?= Date: Thu, 26 Dec 2024 13:59:17 +0100 Subject: [PATCH] Ansible test --- .github/workflows/deploy.yml | 10 ++++++++++ .playbook/inventory | 5 +++++ .playbook/playbook.yml | 25 +++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 .playbook/inventory create mode 100644 .playbook/playbook.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c32c208..ab4f603 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,3 +32,13 @@ jobs: - name: Build app run: npm run build + + - name: Run playbook + uses: dawidd6/action-ansible-playbook@v2 + with: + playbook: playbook.yml + directory: .playbook/ + key: ${{secrets.SSH_KEY}} + options: | + --inventory inventory + --extra-vars repositoryPath=$GITHUB_WORKSPACE diff --git a/.playbook/inventory b/.playbook/inventory new file mode 100644 index 0000000..9c6860a --- /dev/null +++ b/.playbook/inventory @@ -0,0 +1,5 @@ +[beta] +beta.thesociallions.nl + +[production] +thesociallions.nl \ No newline at end of file diff --git a/.playbook/playbook.yml b/.playbook/playbook.yml new file mode 100644 index 0000000..87a1a5a --- /dev/null +++ b/.playbook/playbook.yml @@ -0,0 +1,25 @@ +--- +- name: Copy file to target servers + hosts: beta + tasks: + # Ensure website folder exists + - name: Ensure subfolder exists + ansible.builtin.file: + path: /www/swim + owner: github-actions + group: www-data + state: directory + mode: '0775' + + - name: Copy files + ansible.builtin.copy: + src: "{{ repositoryPath }}/" + dest: /www/swim + mode: '0644' + + - name: Restart nginx + ansible.builtin.service: + name: nginx + state: restarted + + # Handle certificates