From 601c198ded52d4fdf31b67fd1145775f67e3b19a Mon Sep 17 00:00:00 2001 From: db0 Date: Fri, 29 Dec 2023 17:05:32 +0100 Subject: [PATCH] feat: allow pushing new version via github actions --- .github/workflows/deploy.yml | 37 ++++++++++++++++++++++++++++++++++++ ansible/deploy.yml | 27 ++++++++++++++++++++++++++ ansible/inventory.yml | 8 ++++++++ 3 files changed, 72 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 ansible/deploy.yml create mode 100644 ansible/inventory.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..848a85d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,37 @@ +name: Deploy new version + +on: + workflow_dispatch: + +permissions: + contents: write + pull-requests: read + +jobs: + build-n-deploy: + name: Fediseer new release + runs-on: ubuntu-latest + steps: + - name: "✔️ Checkout" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Run playbook + uses: dawidd6/action-ansible-playbook@v2 + with: + # Required, playbook filepath + playbook: ansible/deploy.yml + # Optional, directory where playbooks live + directory: ./ + # Optional, SSH private key + key: ${{secrets.SSH_PRIVATE_KEY}} + # Optional, SSH known hosts file content + known_hosts: | + ${{secrets.SSH_FEDISEER_IP}} ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDuk6apo8+3YzU6WQ7WYu4F/9Pf1Nc1w4QXTqLsIlTmd + # # Optional, encrypted vault password + # vault_password: ${{secrets.VAULT_PASSWORD}} + # Optional, galaxy requirements filepath + # requirements: galaxy-requirements.yml + # Optional, additional flags to pass to ansible-playbook + options: | + --inventory ansible/inventory.yml diff --git a/ansible/deploy.yml b/ansible/deploy.yml new file mode 100644 index 0000000..5e8c690 --- /dev/null +++ b/ansible/deploy.yml @@ -0,0 +1,27 @@ +--- + +- hosts: fediseer + gather_facts: false + + tasks: + - name: Ensure we're on main branch + command: git checkout main + args: + chdir: fediseer/ + tags: + - git + + - name: Update branch + command: git pull + args: + chdir: fediseer/ + tags: + - git + + - name: Make sure a fediseer service unit is restarted + ansible.builtin.systemd_service: + state: restarted + name: fediseer_systemd_10001 + scope: user + tags: + - service \ No newline at end of file diff --git a/ansible/inventory.yml b/ansible/inventory.yml new file mode 100644 index 0000000..6ae2d61 --- /dev/null +++ b/ansible/inventory.yml @@ -0,0 +1,8 @@ +--- + +all: + hosts: + fediseer: + ansible_host: 144.91.110.65 + ansible_become: false + ansible_user: fediseer \ No newline at end of file