Quote Bot CI/CD Pipeline / check (push) Waiting to run
Quote Bot CI/CD Pipeline / Security Scan (push) Waiting to run
Quote Bot CI/CD Pipeline / Build and push to Docker Hub (push) Blocked by required conditions
Quote Bot CI/CD Pipeline / Deploy to VPS via Ansible (push) Blocked by required conditions
40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
# deploy.yml
|
|
- name: Автоматический деплой Telegram-бота
|
|
hosts: all
|
|
|
|
vars:
|
|
image_name: "leor156/quote-bot:{{ image_tag | default('latest') }}"
|
|
container_name: "quote-bot"
|
|
container_state: "started"
|
|
|
|
tasks:
|
|
- name: Убеждаемся, что установлена библиотека Docker для Python
|
|
apt:
|
|
name: python3-docker
|
|
state: present
|
|
update_cache: yes
|
|
|
|
- name: Скачиваем образ бота с Docker Hub
|
|
community.docker.docker_image:
|
|
name: "{{ image_name }}"
|
|
source: pull
|
|
|
|
- name: Запускаем контейнер
|
|
community.docker.docker_container:
|
|
name: "{{ container_name }}"
|
|
image: "{{ image_name }}"
|
|
state: "{{ container_state }}"
|
|
restart_policy: unless-stopped
|
|
pull: always
|
|
env:
|
|
TOKEN: "{{ lookup('env', 'BOT_TOKEN') }}"
|
|
ADMIN_IDS: "{{ lookup('env', 'ADMIN_ID_TG') }}"
|
|
|
|
- name: Чистка
|
|
community.docker.docker_prune:
|
|
images: yes
|
|
images_filters:
|
|
dangling: true
|
|
|
|
|