使用 github 操作从 monorepo 部署单个服务 [英] Deploy individual services from a monorepo using github actions
问题描述
我有大约 10 个单独的微服务,这些微服务主要是用于各种数据处理作业的云功能,它们都位于一个 github 存储库中.
I have around 10 individual micro-services which are mostly cloud functions for various data processing jobs, which all live in a single github repository.
目标是在推送到分支时触发这些服务选择性部署到 Google Cloud Functions - 当单个功能已更新时.
The goal is to trigger the selective deployment of these service to Google Cloud Functions, on push to a branch - when an individual function has been updated.
我必须避免单个服务的更新导致部署所有云功能的情况.
I must avoid the situation in which update of a single service causes the deployment of all the cloud functions.
我当前的存储库结构:
/repo
--/service_A
----/function
----/notebook
--/service_B
----/function
----/notebook
顺便说一句,使用 Github Actions VS Google Cloud Build 实现这种自动化的优缺点是什么?
On a side note, what are the pros/cons of using Github Actions VS Google Cloud Build for such automation?
推荐答案
GitHub Actions 支持具有工作流路径过滤的 monorepos.您可以创建一个工作流,以便在特定路径上的文件发生更改时选择性地触发.
GitHub Actions supports monorepos with path filtering for workflows. You can create a workflow to selectively trigger when files on a specific path change.
https://help.github.com/en/articles/workflow-syntax-for-github-actions#onpushpull_requestpaths
例如,当路径 service_A/
下的任何文件发生更改时,此工作流将在推送时触发(注意 **
glob 以匹配嵌套目录中的文件).
For example, this workflow will trigger on a push when any files under the path service_A/
have changed (note the **
glob to match files in nested directories).
on:
push:
paths:
- 'service_A/**'
这篇关于使用 github 操作从 monorepo 部署单个服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!