import {...} from '@amazon-codecatalyst/blueprint-component.workflows'
可找到工作流程组件 这里。 。 。 .
什么是工作流程组成部分?
CodeCatalyst项目使用一个工作流程来执行一些基于触发的动作. 蓝图团队披露了一些有用的工作流程组件 帮助建立和整理工作流程的 yaml 文件。 见 公开工作流程文件 用于一般用途.
import { WorkflowBuilder, Workflow } from '@amazon-codecatalyst/blueprint-component.workflows'
例1:工作流程构建组件
这是一个帮助构建工作流程定义的类. 然后,这可以交给一个工作流程组件,以便在存储器中渲染.
import { WorkflowBuilder } from '@amazon-codecatalyst/blueprint-component.workflows'
const workflowBuilder = new WorkflowBuilder({} as Blueprint, {
Name: 'my_workflow',
});
// trigger the workflow on pushes to branch 'main'
workflowBuilder.addBranchTrigger(['main']);
// add a build action
workflowBuilder.addBuildAction({
// give the action a name
actionName: 'build_and_do_some_other_stuff',
// the action pulls from source code
input: {
Sources: ['WorkflowSource'],
},
// the output attempts to autodiscover test reports, but not in the node modules
output: {
AutoDiscoverReports: {
Enabled: true,
ReportNamePrefix: AutoDiscovered,
IncludePaths: ['**/*'],
ExcludePaths: ['*/node_modules/**/*'],
},
},
// execute some arbitrary steps
steps: [
'npm install',
'npm run myscript',
'echo hello-world',
],
// add an account connection to the workflow
environment: convertToWorkflowEnvironment(myEnv),
});
例2:工作流程 projen 组件
这是一个 projen 组件,将一个工作流程 yaml 写入一个寄存器 .
import { Workflow } from '@amazon-codecatalyst/blueprint-component.workflows'
...
const repo = new SourceRepository
const blueprint = this;
const workflowDef = workflowBuilder.getDefinition()
// creates a workflow.yaml at .aws/workflows/${workflowDef.name}.yaml
new Workflow(blueprint, repo, workflowDef);
// can also pass in any object and have it rendered as a yaml. This is unsafe and may not produce a valid workflow
new Workflow(blueprint, repo, {... some object ...});
连接到环境
许多工作流程需要在AWS账户连接中运行. 工作流程通过允许行动与环境连接,与会计和 角色名称规范.
import { convertToWorkflowEnvironment } from '@amazon-codecatalyst/blueprint-component.workflows'
const myEnv = new Environment(...);
// can be passed into a workflow constructor
const workflowEnvironment = convertToWorkflowEnvironment(myEnv);
// add a build action
workflowBuilder.addBuildAction({
...
// add an account connection to the workflow
environment: convertToWorkflowEnvironment(myEnv),
});