Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: translate github-dtm-apps and tools #1414

Merged
merged 2 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/plugins/trello.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ This plugin has four outputs:
- `todoListId`
- `doingListId`
- `doneListId`

which can be used by the `trello-github-integ` plugin. Refer to the [`trello-github-integ` plugin doc](./trello-github-integ.md) for more details.
73 changes: 71 additions & 2 deletions docs/use-cases/gitops-python-flask/2-github-dtm-apps.zh.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
# GitHub + GitHub Actions with DTM Apps
# 用 DTM Apps 实现基于 GitHub,Argo CD 和 GitHub Actions 的 CICD 流程

TODO
## 环境变量

你需要先设置如下环境变量:

```bash
export GITHUB_TOKEN="YOUR_GITHUB_TOKEN_HERE"
export IMAGE_REPO_PASSWORD="YOUR_DOCKERHUB_TOKEN_HERE"
```

---

## 配置文件

```yaml
config:
state:
backend: local
options:
stateFile: devstream.state

vars:
GITHUB_USER: YOUR_GITHUB_USER
DOCKERHUB_USER: YOUR_DOCKERHUB_USER

tools:
- name: helm-installer
instanceID: argocd

apps:
- name: myapp1
spec:
language: python
framework: django
repo:
url: github.com/[[ GITHUB_USER ]]/myapp1
token: [[ env GITHUB_TOKEN ]]
repoTemplate:
url: github.com/devstream-io/dtm-repo-scaffolding-python-flask
ci:
- type: github-actions
options:
imageRepo:
user: [[ DOCKERHUB_USER ]]
password: [[ env IMAGE_REPO_PASSWORD ]]
cd:
- type: argocdapp
```

你需要相应更新上述配置文件里的 "YOUR_GITHUB_USER" 和 "YOUR_DOCKERHUB_USER"。

---

## 运行

首先需要初始化:

```bash
# this downloads the required plugins, according to the config file, automatically.
dtm init -f config.yaml
```

<script id="asciicast-EMzx8lzZq5AJpAMoJY23fh8A3" src="https://asciinema.org/a/EMzx8lzZq5AJpAMoJY23fh8A3.js" async></script>

然后运行如下命令让配置生效:

```bash
dtm apply -f config.yaml -y
```

<script id="asciicast-z1XlVm9kGjzArV9aNERD7acfH" src="https://asciinema.org/a/z1XlVm9kGjzArV9aNERD7acfH.js" async></script>
9 changes: 9 additions & 0 deletions docs/use-cases/gitops-python-flask/3-github-dtm-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ DevStream has two abstractions: [Tools](../../core-concepts/tools.md) and [Apps]

[The previous use case](./2-github-dtm-apps.md) uses "Apps". We can also achieve the same result with "Tools", and here's how:

## ENV Vars

The following environment variables are required for this to work:

```bash
export GITHUB_TOKEN="YOUR_GITHUB_TOKEN_HERE"
export IMAGE_REPO_PASSWORD="YOUR_DOCKERHUB_TOKEN_HERE"
```

---

## Config File
Expand Down
105 changes: 103 additions & 2 deletions docs/use-cases/gitops-python-flask/3-github-dtm-tools.zh.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,104 @@
# GitHub + GitHub Actions with DTM Tools
# 用 DTM Tools 实现基于 GitHub,Argo CD 和 GitHub Actions 的 CICD 流程

TODO
DevStream 抽象了2个概念:[Tools](../../core-concepts/tools.md) 和 [Apps](../../core-concepts/apps.md)。

在[前一个用户场景](./2-github-dtm-apps.md) 里介绍了 "Apps",你可以用 "Tools" 实现一样的效果。具体方法如下:

## 环境变量

你需要先设置如下环境变量:

```bash
export GITHUB_TOKEN="YOUR_GITHUB_TOKEN_HERE"
export IMAGE_REPO_PASSWORD="YOUR_DOCKERHUB_TOKEN_HERE"
```

---

## 配置文件

```yaml
config:
state:
backend: local
options:
stateFile: devstream.state

vars:
GITHUB_USER: YOUR_GITHUB_USER
DOCKERHUB_USER: YOUR_DOCKERHUB_USER

tools:
- name: repo-scaffolding
instanceID: myapp1
options:
destinationRepo:
owner: [[ GITHUB_USER ]]
name: myapp1
branch: main
scmType: github
token: [[ env GITHUB_TOKEN ]]
sourceRepo:
org: devstream-io
name: dtm-repo-scaffolding-python-flask
scmType: github
- name: github-actions
instanceID: flask
dependsOn: [ repo-scaffolding.myapp1 ]
options:
scm:
owner: [[ GITHUB_USER ]]
name: myapp1
scmType: github
token: [[ env GITHUB_TOKEN ]]
pipeline:
configLocation: https://raw.githubusercontent.com/devstream-io/dtm-pipeline-templates/main/github-actions/workflows/main.yml
language:
name: python
framework: flask
imageRepo:
user: [[ DOCKERHUB_USER ]]
password: [[ env IMAGE_REPO_PASSWORD ]]
- name: helm-installer
instanceID: argocd
- name: argocdapp
instanceID: default
dependsOn: [ "helm-installer.argocd", "github-actions.flask" ]
options:
app:
name: myapp1
namespace: argocd
destination:
server: https://kubernetes.default.svc
namespace: default
source:
valuefile: values.yaml
path: helm/myapp1
repoURL: ${{repo-scaffolding.myapp1.outputs.repoURL}}
token: [[ env GITHUB_TOKEN ]]
imageRepo:
user: [[ DOCKERHUB_USER ]]
```

你需要相应更新上述配置文件里的 "YOUR_GITHUB_USER" 和 "YOUR_DOCKERHUB_USER"。

---

## 运行

首先需要初始化:

```bash
# this downloads the required plugins, according to the config file, automatically.
dtm init -f config.yaml
```

<script id="asciicast-EMzx8lzZq5AJpAMoJY23fh8A3" src="https://asciinema.org/a/EMzx8lzZq5AJpAMoJY23fh8A3.js" async></script>

然后运行如下命令让配置生效:

```bash
dtm apply -f config.yaml -y
```

(省略了动图和视频等)
12 changes: 6 additions & 6 deletions docs/use-cases/gitops-python-flask/4-gitlab-dtm-apps.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

DevStream 将使用下面的插件来实现[第 0 节](#)中描述的目标:

1. [gitlab-ce-docker](../plugins/gitlab-ce-docker.md):用于在 Docker 中安装 GitLab;
2. [repo-scaffolding](../plugins/repo-scaffolding.md): 用于在 GitLab 上创建一个 Python Web 应用程序仓库;
3. [gitlab-ci](../plugins/gitlab-ci.md):用于为我们创建的仓库设置基本的 CI 流水线;
4. [helm-installer](../plugins/helm-installer/helm-installer.md): 用于在 Kubernetes 集群中安装 Argo CD;
5. [argocdapp](../plugins/argocdapp.md): 用于创建一个 Argo CD 应用程序,来部署第 1 步中生成的 Web 应用程序。
1. [gitlab-ce-docker](../../plugins/gitlab-ce-docker.md):用于在 Docker 中安装 GitLab;
2. [repo-scaffolding](../../plugins/repo-scaffolding.md): 用于在 GitLab 上创建一个 Python Web 应用程序仓库;
3. [gitlab-ci](../../plugins/gitlab-ci.md):用于为我们创建的仓库设置基本的 CI 流水线;
4. [helm-installer](../../plugins/helm-installer/helm-installer.md): 用于在 Kubernetes 集群中安装 Argo CD;
5. [argocdapp](../../plugins/argocdapp.md): 用于创建一个 Argo CD 应用程序,来部署第 1 步中生成的 Web 应用程序。

我们将分成两个步骤来完成这些目标:

Expand Down Expand Up @@ -58,7 +58,7 @@ sh -c "$(curl -fsSL https://download.devstream.io/download.sh)

> 可选:你可以把 `dtm` 移动到 $PATH 环境变量中的某个目录下。例如:`mv dtm /usr/local/bin/`。这样,你就可以直接运行 `dtm` 而不需要再加上 `./` 前缀了。
>
> 更多安装方式详见[安装 dtm](../install.zh.md)。
> 更多安装方式详见[安装 dtm](../../install.zh.md)。

## 2 安装 GitLab 和 Argo CD

Expand Down