Skip to content

Setup cd workflow#2

Merged
Fl1riX merged 2 commits into
mainfrom
setup/cd-workflow
Mar 11, 2026
Merged

Setup cd workflow#2
Fl1riX merged 2 commits into
mainfrom
setup/cd-workflow

Conversation

@Fl1riX
Copy link
Copy Markdown
Owner

@Fl1riX Fl1riX commented Mar 11, 2026

Summary by Sourcery

Deployment:

  • Введён workflow GitHub Actions, который при пушах в ветку main подключается по SSH к целевому серверу, подтягивает последний код, пересобирает Docker-сервисы и очищает неиспользуемые ресурсы Docker.
Original summary in English

Summary by Sourcery

Deployment:

  • Introduce a GitHub Actions workflow that SSHes into the target server on pushes to main, pulls the latest code, rebuilds Docker services, and prunes unused Docker resources.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Mar 11, 2026

Руководство для ревьюера

Добавляет CD‑workflow GitHub Actions, который при каждом пуше в ветку main деплоит её на удалённый сервер по SSH, используя docker compose для сборки и перезапуска и включая управление конкуренцией (concurrency).

Диаграмма последовательности для CD‑workflow деплоя в GitHub Actions

sequenceDiagram
    actor Developer
    participant GitHub as GitHub_Repo
    participant Actions as GitHub_Actions_Workflow
    participant SSH as SSH_Action
    participant Server as Remote_Server
    participant Docker as Docker_Engine

    Developer->>GitHub: Push commit to main
    GitHub-->>Actions: Trigger Deploy workflow (on push to main)

    Actions->>Actions: Apply concurrency group deploy-${{github.ref}}
    Actions->>SSH: Run appleboy/ssh-action@v1.0.0
    SSH->>Server: SSH connect using SSH_HOST, SSH_USER, SSH_DEPLOY_PRIVATE_KEY

    SSH->>Server: cd ~/SteelTime
    SSH->>Server: git fetch origin main
    SSH->>Server: git reset --hard origin/main

    SSH->>Docker: docker compose up -d --build
    SSH->>Docker: docker system prune -f

    Docker-->>Server: Containers built and restarted
    Server-->>Actions: Deployment commands completed
    Actions-->>Developer: Workflow run finished
Loading

Изменения по файлам

Change Details Files
Вводит deploy‑workflow GitHub Actions, который подключается к серверу по SSH и пере‑деплоит приложение при пушах в main.
  • Настроить запуск workflow при пушах в ветку main.
  • Добавить настройки concurrency, чтобы одновременно выполнялся только один деплой на ветку и чтобы новые пуши отменяли запущенные деплои.
  • Использовать appleboy/ssh-action с репозиторными SSH‑секретами для подключения к целевому серверу.
  • Удалённо запускать скрипт деплоя, который обновляет Git‑репозиторий до origin/main, пересобирает и перезапускает сервисы через docker compose и очищает неиспользуемые ресурсы Docker.
.github/workflows/deploy.yml

Подсказки и команды

Взаимодействие с Sourcery

  • Запустить новое ревью: Оставьте комментарий @sourcery-ai review в pull request.
  • Продолжить обсуждения: Отвечайте напрямую на комментарии ревью от Sourcery.
  • Создать GitHub‑issue из комментария ревью: Попросите Sourcery создать issue из комментария ревью, ответив на него. Вы также можете ответить на комментарий ревью с @sourcery-ai issue, чтобы создать issue на его основе.
  • Сгенерировать заголовок pull request: Напишите @sourcery-ai где‑нибудь в заголовке pull request, чтобы сгенерировать заголовок в любой момент. Также можно оставить комментарий @sourcery-ai title в pull request, чтобы (пере)сгенерировать заголовок в любой момент.
  • Сгенерировать краткое описание pull request: Напишите @sourcery-ai summary где‑нибудь в теле pull request, чтобы сгенерировать описание PR в нужном месте. Также можно оставить комментарий @sourcery-ai summary в pull request, чтобы (пере)сгенерировать summary в любой момент.
  • Сгенерировать руководство для ревьюера: Оставьте комментарий @sourcery-ai guide в pull request, чтобы (пере)сгенерировать руководство для ревьюера в любой момент.
  • Закрыть все комментарии Sourcery: Оставьте комментарий @sourcery-ai resolve в pull request, чтобы отметить все комментарии Sourcery как решённые. Полезно, если вы уже учли все замечания и больше не хотите их видеть.
  • Отклонить все ревью Sourcery: Оставьте комментарий @sourcery-ai dismiss в pull request, чтобы отклонить все существующие ревью Sourcery. Особенно полезно, если вы хотите начать с чистого листа с новым ревью — не забудьте оставить комментарий @sourcery-ai review, чтобы запустить новое ревью!

Настройка под себя

Перейдите в свою панель управления, чтобы:

  • Включать или отключать функции ревью, такие как сгенерированное Sourcery описание pull request, руководство для ревьюера и другие.
  • Изменить язык ревью.
  • Добавлять, удалять или редактировать собственные инструкции для ревью.
  • Настраивать другие параметры ревью.

Получение помощи

Original review guide in English

Reviewer's Guide

Adds a GitHub Actions CD workflow that deploys the main branch to a remote server over SSH on each push to main, using docker compose for build and restart and enabling concurrency control.

Sequence diagram for GitHub Actions CD deploy workflow

sequenceDiagram
    actor Developer
    participant GitHub as GitHub_Repo
    participant Actions as GitHub_Actions_Workflow
    participant SSH as SSH_Action
    participant Server as Remote_Server
    participant Docker as Docker_Engine

    Developer->>GitHub: Push commit to main
    GitHub-->>Actions: Trigger Deploy workflow (on push to main)

    Actions->>Actions: Apply concurrency group deploy-${{github.ref}}
    Actions->>SSH: Run appleboy/ssh-action@v1.0.0
    SSH->>Server: SSH connect using SSH_HOST, SSH_USER, SSH_DEPLOY_PRIVATE_KEY

    SSH->>Server: cd ~/SteelTime
    SSH->>Server: git fetch origin main
    SSH->>Server: git reset --hard origin/main

    SSH->>Docker: docker compose up -d --build
    SSH->>Docker: docker system prune -f

    Docker-->>Server: Containers built and restarted
    Server-->>Actions: Deployment commands completed
    Actions-->>Developer: Workflow run finished
Loading

File-Level Changes

Change Details Files
Introduce a GitHub Actions deploy workflow that SSHes into the server and redeploys the app on pushes to main.
  • Configure workflow to trigger on pushes to the main branch.
  • Add concurrency settings to ensure only one deploy per branch runs at a time and cancel in-progress runs for new pushes.
  • Use appleboy/ssh-action with repository SSH secrets to connect to the target server.
  • Run a deployment script remotely that updates the Git repo to origin/main, rebuilds and restarts via docker compose, and prunes unused Docker resources.
.github/workflows/deploy.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - я нашёл одну проблему и оставил несколько общих замечаний:

  • Подумайте о том, чтобы сузить действие команды docker system prune -f до более таргетированной очистки (например, docker image prune или ресурсов с метками), чтобы избежать случайного удаления несвязанных контейнеров/томов на хосте.
  • Имеет смысл добавить флаг --pull к команде docker compose up -d --build, чтобы деплой всегда использовал последние базовые образы, а не полагался на потенциально устаревшие кэшированные слои.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider narrowing `docker system prune -f` to a more targeted cleanup (e.g., `docker image prune` or labelled resources) to avoid accidentally removing unrelated containers/volumes on the host.
- You might want to add `--pull` to `docker compose up -d --build` so that the deployment always uses the latest base images instead of relying on potentially stale cached layers.

## Individual Comments

### Comment 1
<location path=".github/workflows/deploy.yml" line_range="28" />
<code_context>
+            git fetch origin main
+            git reset --hard origin/main
+            docker compose up -d --build
+            docker system prune -f
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Re-evaluate using `docker system prune -f` on a shared host, as it can affect other projects.

This command removes all unused containers, networks, images, and build cache on the entire host, which can disrupt other stacks on a shared server. If you only need to clean up artifacts from this project, please use a more targeted approach (e.g., pruning only unused images or using labels/compose options) to avoid impacting other workloads.
</issue_to_address>

Sourcery бесплатно для open source — если вам нравятся наши обзоры, пожалуйста, поделитесь ими ✨
Помогите мне стать полезнее! Пожалуйста, ставьте 👍 или 👎 на каждом комментарии — я использую этот фидбек, чтобы улучшать обзоры.
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • Consider narrowing docker system prune -f to a more targeted cleanup (e.g., docker image prune or labelled resources) to avoid accidentally removing unrelated containers/volumes on the host.
  • You might want to add --pull to docker compose up -d --build so that the deployment always uses the latest base images instead of relying on potentially stale cached layers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider narrowing `docker system prune -f` to a more targeted cleanup (e.g., `docker image prune` or labelled resources) to avoid accidentally removing unrelated containers/volumes on the host.
- You might want to add `--pull` to `docker compose up -d --build` so that the deployment always uses the latest base images instead of relying on potentially stale cached layers.

## Individual Comments

### Comment 1
<location path=".github/workflows/deploy.yml" line_range="28" />
<code_context>
+            git fetch origin main
+            git reset --hard origin/main
+            docker compose up -d --build
+            docker system prune -f
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Re-evaluate using `docker system prune -f` on a shared host, as it can affect other projects.

This command removes all unused containers, networks, images, and build cache on the entire host, which can disrupt other stacks on a shared server. If you only need to clean up artifacts from this project, please use a more targeted approach (e.g., pruning only unused images or using labels/compose options) to avoid impacting other workloads.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/deploy.yml
@Fl1riX Fl1riX merged commit 710277c into main Mar 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant