feature ci/cd cleaning

This commit is contained in:
2026-03-01 19:13:21 +03:00
parent 236f5d041b
commit 395abdc569
2 changed files with 29 additions and 10 deletions

View File

@@ -8,18 +8,21 @@ jobs:
deploy:
runs-on: node-ansible
steps:
- name: Setup SSH key
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > /tmp/id_fin
chmod 600 /tmp/id_fin
- name: Install Ansible collection
run: ansible-galaxy collection install community.docker
- name: Create inventory
run: echo "${{ secrets.INVENTORY }}" > inventory.ini
- name: Create secrets.yml
run: echo "${{ secrets.SECRETS }}" > secrets.yml
- name: Create .env file
run: echo "${{ secrets.RUNNER_ENV }}" > .env
- name: Checkout only deploy.yml
uses: actions/checkout@v4
with:
@@ -28,6 +31,7 @@ jobs:
path: tmp-repo
sparse-checkout: |
ansible/deploy.yml
- name: Run Ansible playbook
run: ansible-playbook -i inventory.ini tmp-repo/ansible/deploy.yml -e @secrets.yml -e env_file="$(pwd)/.env"
env:
@@ -39,10 +43,13 @@ jobs:
needs: deploy
steps:
- uses: actions/checkout@v4
- name: Create .env file
run: echo "${{ secrets.WEDDING_SITE_ENV }}" > .env
- name: Build image
run: docker build -t back:latest -f docker/dockerfile .
- name: Start docker-compose
run: docker compose --env-file .env -f docker/docker-compose.yaml up -d

View File

@@ -3,10 +3,18 @@
vars:
env_file: $(pwd)/.env
tasks:
- name: Install wget
apt:
name: wget
state: present
update_cache: yes
- name: Install Docker
shell: curl -fsSL https://get.docker.com | sh
args:
creates: /usr/bin/docker
- name: Ensure /opt/infra exists
file:
path: /opt/infra
@@ -14,6 +22,7 @@
owner: root
group: root
mode: '0755'
- name: Copy .env to remote
copy:
src: "{{ env_file }}"
@@ -22,15 +31,18 @@
group: root
mode: '0600'
- name: Download nginx
shell: wget -O /opt/infra/nginx.yaml "{{ URL for docker-compose nginx }}"
args:
creates: /opt/infra/nginx.yaml
- name: Download node-docker.yaml
shell: wget -O /opt/infra/node-docker.yaml "{{ gitea_instance_url }}"
args:
creates: /opt/infra/node-docker.yaml
# - name: Start docker compose via module
# community.docker.docker_compose_v2:
# project_src: /opt/infra
# files:
# - node-docker.yaml
# state: present
# restarted: true
- name: Start docker compose
- name: Start node-docker
shell: docker-compose -f /opt/infra/node-docker.yaml up -d
- name: Start nginx
shell: docker-compose -f /opt/infra/nginx.yaml up -d