AWS CodePipeline 添加来自 CloudFormation 模板的 Github 源

AWS CodePipeline Add Github Source from CloudFormation Template

我正在使用本教程中的 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 定义为资源以及如何处理私有存储库的身份验证?

对于 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

有关详细信息,请单击

code pipeline thirdparty source provider

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

github personal token intergration into code pipeline