如何在管道中运行脚本?

问题描述 投票:0回答:1

我在我的Bitbucket管道中使用管道atlassian / aws-s3-deploy:0.4.0将其部署到AWS s3。这很好用,但是我只需要为index.html

设置Cache-Control。

如何在管道中运行代码,以便仍然可以使用aws cli工具?这不应该是另一步骤,因为部署过程应该是一个步骤。

我当前的脚本如下:

image: node:10.15.3

pipelines:
default:
    - step:
        name: Build
        caches:
        - node
        script:
        - npm install
        - npm run build
        artifacts:
        - dist/**
    - step:
        name: Deploy
        trigger: manual
        script:
        - pipe: atlassian/aws-s3-deploy:0.4.0
            variables:
            AWS_DEFAULT_REGION: 'eu-central-1'
            S3_BUCKET: '***'
            LOCAL_PATH: 'dist'
        - aws s3 cp dist/index.html s3://***/index.html --cache-control no-cache,no-store

凭证是通过项目秘密变量提供的。

谢谢!

amazon-web-services bitbucket-pipelines
1个回答
0
投票

您可以在同一步骤中安装aws cli:

- step:
    name: Deploy
    trigger: manual
    # use python docker image so pip is available
    image: python:3.7
    script:
      - pipe: atlassian/aws-s3-deploy:0.4.0
          variables:
            AWS_DEFAULT_REGION: 'eu-central-1'
            S3_BUCKET: '***'
            LOCAL_PATH: 'dist'
    # install the aws cli
      - pip3 install awscli --upgrade --user
      - aws s3 cp dist/index.html s3://***/index.html --cache-control no-cache,no-store
© www.soinside.com 2019 - 2024. All rights reserved.