首页 > 解决方案 > AWS CodePipeline 从 CloudFormation 模板添加 Github 源

问题描述

我正在使用本教程中的 Cloudformation 堆栈:

https://aws.amazon.com/blogs/compute/continuous-deployment-for-serverless-applications/

它创建一个以 CodeCommit 存储库为源的管道。我想将其切换到 Github 存储库。这是定义此资源的代码:

 Pipeline:
        Type: AWS::CodePipeline::Pipeline
        Properties:
            ArtifactStore: 
                Location: !Ref BuildArtifactsBucket
                Type: S3
            Name: !Sub ${ServiceName}_pipeline
            RoleArn: !GetAtt PipelineExecutionRole.Arn
            Stages:
                - Name: Source
                  Actions:
                    - Name: CodeCommitRepo
                      ActionTypeId:
                        Category: Source
                        Owner: AWS
                        Provider: CodeCommit
                        Version: 1
                      Configuration:
                        RepositoryName: !Sub '${ServiceName}_repo'
                        BranchName: master
                      OutputArtifacts:
                        - Name: SourceZip
                      RunOrder: 1

GitHub 如何定义为资源以及如何处理私有存储库的身份验证?

标签: amazon-web-servicesamazon-cloudformationaws-codepipeline

解决方案


例如,对于 github,您需要用 github 替换提供者

 Pipeline:
        Type: AWS::CodePipeline::Pipeline
        Properties:
            ArtifactStore: 
                Location: !Ref BuildArtifactsBucket
                Type: S3
            Name: !Sub ${ServiceName}_pipeline
            RoleArn: !GetAtt PipelineExecutionRole.Arn
            Stages:
                - Name: Source
                  Actions:
                    - Name: GithubRepo
                      ActionTypeId:
                        Category: Source
                        Owner: ThirdParty
                        Provider: GitHub
                        Version: 1
                      Configuration:
                        "Owner": "MyGitHubAccountName",
                        "Repo": "MyGitHubRepositoryName",
                        "PollForSourceChanges": "false",
                        "Branch": "master",
                        "OAuthToken": "****"

                      OutputArtifacts:
                        - Name: SourceZip
                      RunOrder: 1

更多信息请点击

代码管道第三方源提供者

在这里,是如何获取 github 个人令牌并将其插入到您的代码管道中

github个人令牌集成到代码管道中


推荐阅读