Setup cd workflow#2
Merged
Merged
Conversation
Contributor
Руководство для ревьюераДобавляет CD‑workflow GitHub Actions, который при каждом пуше в ветку main деплоит её на удалённый сервер по SSH, используя docker compose для сборки и перезапуска и включая управление конкуренцией (concurrency). Диаграмма последовательности для CD‑workflow деплоя в GitHub ActionssequenceDiagram
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
Изменения по файлам
Подсказки и командыВзаимодействие с Sourcery
Настройка под себяПерейдите в свою панель управления, чтобы:
Получение помощи
Original review guide in EnglishReviewer's GuideAdds 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 workflowsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
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 -fto a more targeted cleanup (e.g.,docker image pruneor labelled resources) to avoid accidentally removing unrelated containers/volumes on the host. - You might want to add
--pulltodocker compose up -d --buildso 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Deployment:
mainподключается по SSH к целевому серверу, подтягивает последний код, пересобирает Docker-сервисы и очищает неиспользуемые ресурсы Docker.Original summary in English
Summary by Sourcery
Deployment: