From 103039e0496edd379a9cfa782c5fa340829a3611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Fernandes?= Date: Sun, 1 Sep 2024 04:27:39 +0100 Subject: [PATCH] host continuous deploy git actions and runner --- .gitea/workflows/host.yml | 45 +++++++++++++++++++++++++++++----- services/git-runner/Dockerfile | 3 +++ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 services/git-runner/Dockerfile diff --git a/.gitea/workflows/host.yml b/.gitea/workflows/host.yml index 38b943f..ae7e581 100644 --- a/.gitea/workflows/host.yml +++ b/.gitea/workflows/host.yml @@ -1,17 +1,50 @@ name: deploy host on: push: - paths_ignore: + paths-ignore: - "services/**" - "docs/**" - ".gitea/workflows/**services**.yml" jobs: - build: - runs-on: ubuntu-latest + setup-runner: + runs-on: homesrv01 + container: + image: catthehacker/ubuntu:act-latest + volumes: + - workspace:/workspace + steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build project + + - name: build git runner + shell: bash run: | - npm install - npm run build \ No newline at end of file + docker build ${{gitea.workspace}}/services/git-runner --tag homesrv/git-runner + + ansible-playbook: + runs-on: homesrv01 + container: + image: homesrv/git-runner + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up SSH + run: | + echo "${{secrets.SSH_PRIVATE_KEY}}" > ~/.ssh/private_key.pem + chmod 600 ~/.ssh/private_key.pem + + + - name: get version + run: | + lsb_release -a + + + - name: Run Ansible Playbook + env: + ANSIBLE_HOST_KEY_CHECKING: False + ANSIBLE_BECOME_PASS: ${{secrets.ANSIBLE_BECOME_PASS}} + run: | + ansible-playbook -i ${{secrets.SERVER_ADDRESS}}, ${{gitea.workspace}}/ansible/site.yml --private-key ~/.ssh/private_key.pem -u ${{secrets.ANSIBLE_USER}} diff --git a/services/git-runner/Dockerfile b/services/git-runner/Dockerfile new file mode 100644 index 0000000..60b5ede --- /dev/null +++ b/services/git-runner/Dockerfile @@ -0,0 +1,3 @@ +FROM catthehacker/ubuntu:act-latest +RUN apt-get update && apt install software-properties-common && add-apt-repository --yes --update ppa:ansible/ansible && apt-get install -y ansible +