Bitbucket 管道将不需要的文件上传到 S3

Max*_*ion 1 bitbucket amazon-s3 amazon-web-services bitbucket-pipelines

我有一个包含以下文件的存储库:

app.js
bitbucket-pipelines.yml
package-lock.json
package.json
Run Code Online (Sandbox Code Playgroud)

我想将node_modules/ app.js package.json它们压缩并上传到 S3。我写了下面的管道:

image: atlassian/default-image:2

pipelines:
  branches: # Pipelines should that will be triggered when a push is made in the below branch
    master:
      - step:
          name: Deploy to S3
          script:
            - zip -r archive.zip node_modules/ app.js package.json
            - pipe: atlassian/aws-s3-deploy:0.5.0
              variables:
                AWS_ACCESS_KEY_ID: 
                AWS_SECRET_ACCESS_KEY: 
                AWS_DEFAULT_REGION: 
                COMMAND: 'upload-only'
                ZIP_FILE: 'archive.zip'
                S3_BUCKET: 'lambda-bucket/lambda'
                LOCAL_PATH: '$(pwd)'
                ACL: 'private'
Run Code Online (Sandbox Code Playgroud)

管道成功运行,但会将存储库中的所有文件(包括新创建的 zip)上传到 S3。如何确保管道只上传 zip 文件?

Ian*_*ney 5

基于https://support.atlassian.com/bitbucket-cloud/docs/deploy-to-aws-with-s3/

image: atlassian/default-image:2

pipelines:
  branches: # Pipelines should that will be triggered when a push is made in the below branch
    master:
      - step:
          name: Deploy to S3
          script:
            - mkdir artifact
            - zip -r artifact/archive.zip node_modules/ app.js package.json
            - pipe: atlassian/aws-s3-deploy:0.5.0
              variables:
                AWS_ACCESS_KEY_ID: 
                AWS_SECRET_ACCESS_KEY: 
                AWS_DEFAULT_REGION: 
                COMMAND: 'upload-only'
                S3_BUCKET: 'lambda-bucket/lambda'
                LOCAL_PATH: 'artifact'
                ACL: 'private'
Run Code Online (Sandbox Code Playgroud)

这将创建一个新文件夹 ( mkdir artifact),在该文件夹 ( ) 中构建 zipzip -r artifact/archive.zip ...并上传该文件夹LOCAL_PATH: 'artifact'