<commit_before>AWSTemplateFormatVersion: "2010-09-09"
Description: Serverless deployment pipeline for a website powered by Hexo, including a CDN and HTTPS/Cert
Parameters:
  GithubOauthToken:
    Type: String
  GithubRepoOwner:
    Type: String
  GithubRepoName:
    Type: String
  GithubRepoBranch:
    Type: String
    Default: master
  DomainName:
    Type: String
  DeploymentStage:
    Type: String
    Default: prod
Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
      - Label:
          default: Source Code Repository
        Parameters:
          - GithubRepoOwner
          - GithubRepoName
          - GithubRepoBranch
          - GithubOauthToken
Resources:
  WebsiteBucket:
    Type: AWS::S3::Bucket
    Properties:
      AccessControl: PublicRead
      WebsiteConfiguration:
        IndexDocument: index.html
  ArtifactStoreBucket:
    Type: AWS::S3::Bucket
    Properties:
      VersioningConfiguration:
        Status: Enabled
      AccessControl: BucketOwnerFullControl
  Pipeline:
    Type: AWS::CodePipeline::Pipeline
    Properties:
      RoleArn: !GetAtt [PipelineRole, Arn]
      ArtifactStore:
        Location:
          Ref:
            ArtifactStoreBucket
        Type: S3
      Stages:
        - Name: Source
          Actions:
            - Name: SourceAction
              ActionTypeId:
                Category: Source
                Owner: ThirdParty
                Version: 1
                Provider: GitHub
              InputArtifacts: []
              OutputArtifacts:
                - Name: SourceOutput
              Configuration:
                Owner: !Ref GithubRepoOwner
                Repo: !Ref GithubRepoName
                Branch: !Ref GithubRepoBranch
                OAuthToken: !Ref GithubOauthToken
              RunOrder: 1
        - Name: DeployWebsite
          Actions:
          - Name: DeployWebsiteAction
            ActionTypeId:
              Category: Build
              Owner: AWS
              Version: 1
              Provider: CodeBuild
            InputArtifacts:
              - Name: SourceOutput
            OutputArtifacts:
              - Name: DeployWebsiteActionOutput
            Configuration:
              ProjectName:
                Ref: DeployWebsiteBuild
            RunOrder: 2

  PipelineRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          Effect: Allow
          Principal:
            Service: codepipeline.amazonaws.com
          Action: sts:AssumeRole
      Path: /
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AdministratorAccess

  DeployWebsiteBuild:
    Type: AWS::CodeBuild::Project
    Properties:
      Artifacts:
        Type: CODEPIPELINE
      Environment:
        ComputeType: BUILD_GENERAL1_SMALL
        Image: aws/codebuild/eb-nodejs-4.4.6-amazonlinux-64:2.1.3
        Type: LINUX_CONTAINER
        EnvironmentVariables:
          - Name: WEBSITE_BUCKET
            Value: !Ref WebsiteBucket
      Name: !Sub DeployWebsiteBuild-${DeploymentStage}
      ServiceRole: !Ref DeployWebsiteRole
      Source:
        Type: CODEPIPELINE
        BuildSpec: |
          version: 0.1
          phases:
            install:
              commands:
                - npm install
            build:
              commands:
                - node_modules/.bin/hexo deploy<commit_msg>deploy build to s3<commit_after>AWSTemplateFormatVersion: "2010-09-09"
Description: Serverless deployment pipeline for a website powered by Hexo, including a CDN and HTTPS/Cert
Parameters:
  GithubOauthToken:
    Type: String
  GithubRepoOwner:
    Type: String
  GithubRepoName:
    Type: String
  GithubRepoBranch:
    Type: String
    Default: master
  DomainName:
    Type: String
  DeploymentStage:
    Type: String
    Default: prod
Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
      - Label:
          default: Source Code Repository
        Parameters:
          - GithubRepoOwner
          - GithubRepoName
          - GithubRepoBranch
          - GithubOauthToken
Resources:
  WebsiteBucket:
    Type: AWS::S3::Bucket
    Properties:
      AccessControl: PublicRead
      WebsiteConfiguration:
        IndexDocument: index.html
  ArtifactStoreBucket:
    Type: AWS::S3::Bucket
    Properties:
      VersioningConfiguration:
        Status: Enabled
      AccessControl: BucketOwnerFullControl
  Pipeline:
    Type: AWS::CodePipeline::Pipeline
    Properties:
      RoleArn: !GetAtt [PipelineRole, Arn]
      ArtifactStore:
        Location:
          Ref:
            ArtifactStoreBucket
        Type: S3
      Stages:
        - Name: Source
          Actions:
            - Name: SourceAction
              ActionTypeId:
                Category: Source
                Owner: ThirdParty
                Version: 1
                Provider: GitHub
              InputArtifacts: []
              OutputArtifacts:
                - Name: SourceOutput
              Configuration:
                Owner: !Ref GithubRepoOwner
                Repo: !Ref GithubRepoName
                Branch: !Ref GithubRepoBranch
                OAuthToken: !Ref GithubOauthToken
              RunOrder: 1
        - Name: DeployWebsite
          Actions:
          - Name: DeployWebsiteAction
            ActionTypeId:
              Category: Build
              Owner: AWS
              Version: 1
              Provider: CodeBuild
            InputArtifacts:
              - Name: SourceOutput
            OutputArtifacts:
              - Name: DeployWebsiteActionOutput
            Configuration:
              ProjectName:
                Ref: DeployWebsiteBuild
            RunOrder: 2

  PipelineRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          Effect: Allow
          Principal:
            Service: codepipeline.amazonaws.com
          Action: sts:AssumeRole
      Path: /
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AdministratorAccess

  DeployWebsiteBuild:
    Type: AWS::CodeBuild::Project
    Properties:
      Artifacts:
        Type: CODEPIPELINE
      Environment:
        ComputeType: BUILD_GENERAL1_SMALL
        Image: aws/codebuild/eb-nodejs-4.4.6-amazonlinux-64:2.1.3
        Type: LINUX_CONTAINER
        EnvironmentVariables:
          - Name: WEBSITE_BUCKET
            Value: !Ref WebsiteBucket
      Name: !Sub DeployWebsiteBuild-${DeploymentStage}
      ServiceRole: !Ref DeployWebsiteRole
      Source:
        Type: CODEPIPELINE
        BuildSpec: |
          version: 0.1
          phases:
            install:
              commands:
                - npm install
            build:
              commands:
                - node_modules/.bin/hexo deploy
            post_build:
              commands:
                - aws s3 sync public/ s3://$WEBSITE_BUCKET/
{'fraction_non_alphanumeric': 0.06216490363715404, 'fraction_numerical': 0.010288364005216636, 'mean_word_length': 1.6597302504816955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '117780', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1802, 'n_words': 419}