CI,CD

MinJee Lee·2021년 5월 24일
0

CI,CD

목록 보기
1/1
post-thumbnail

CI(Continuous Integration), CD(Continuous Delivery)

name: Deploy to Production
  
on: 
    push:
      branches:
        - master
  
jobs:
    deploy:
      name: Build, Deploy to S3 bucket
      runs-on: [ubuntu-latest]
  
      strategy:
        matrix:
          node-version: [12.16.x]
          appname: [doradora]
          deploy-group: [doradora]
          s3-bucket: [doradora1]
          s3-filename: [build]
  
      steps:
        - uses: actions/checkout@v2
  
        - name: Use Node.js ${{ matrix.node-version }}
          uses: actions/setup-node@v1
          with:
            node-version: ${{ matrix.node-version }}
  
        - name: Npm install
          run: npm install
  
        - name: Build
          run: npm run build
        - name: Copy file
          # You may pin to the exact commit or the version.
          # uses: canastro/copy-action@7ddff6fc153a2ea2cd0fb88ed9750544c051e399
          uses: canastro/copy-action@0.0.2
          with: 
            # Source file
            source: appspec.yml
            # Target file
            target: build/appspec.yml            
            
        - name: copy script file
          run: | 
            cp -r script --update build/
            
            # Install AWS CLI 2
        - name: Install AWS CLI 2
          run: |
           curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
           unzip awscliv2.zip
           sudo ./aws/install --update
 
          
        - name: Easy Zip Files
  # You may pin to the exact commit or the version.
  # uses: vimtor/action-zip@5f1c4aa587ea41db1110df6a99981dbe19cee310
          uses: vimtor/action-zip@v1
          with:
              # Files or directories to zip
              files: build 
              # Name of output zip file
              dest: artifact/build.zip
              # Whether to add subdirectories to simply zip all files to the root
              recursive: true
            
        - name: Transfer to S3 for serving static
          uses: jakejarvis/s3-sync-action@master
          with:
            args: --acl public-read --follow-symlinks --delete
          env:
            AWS_S3_BUCKET: doradora1
            AWS_ACCESS_KEY_ID: ${{ secrets. AWS_IAM_MANAGER_KEY_ID }}
            AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_IAM_MANAGER_SECRET_ACCESS_KEY }}
            AWS_REGION: us-east-2
            SOURCE_DIR: 'artifact'
            
            # Configure AWS credentials
        - name: Configure AWS credentials
          uses: aws-actions/configure-aws-credentials@v1
          with:
           aws-access-key-id: ${{ secrets. AWS_IAM_MANAGER_KEY_ID }}
           aws-secret-access-key: ${{ secrets.AWS_IAM_MANAGER_SECRET_ACCESS_KEY }}
           aws-region: us-east-2
           
      # Create deployment to CodeDeploy
        - name: AWS Create Deployment
          run: |
           aws deploy create-deployment \
           --application-name ${{ matrix.appname }} \
           --deployment-config-name CodeDeployDefault.OneAtATime \
           --deployment-group-name ${{ matrix.deploy-group }} \
           --file-exists-behavior OVERWRITE \
           --s3-location bucket=${{ matrix.s3-bucket }},key=${{ matrix.s3-filename }}.zip,bundleType=zip \

0개의 댓글