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

Bitbucket pipeline uploading unwanted files to S3

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

app.js
bitbucket-pipelines.yml
package-lock.json
package.json

我想压缩 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'

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

基于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'

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