更改后的网页文件不会由 aws CDK s3deploy.Source.asset 上传

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

我有一个通过 gitlab 管道使用 CDK 部署的 aws s3 + cloudfront 网页。 (代码仓库在这里:https://github.com/ruwanindika/website

Gitlab 阶段是“构建”-->“部署”

  1. 在构建阶段我添加如下版本号
script:
    - sed -i "s/%%VERSION%%/$CI_COMMIT_SHORT_SHA/" /builds/personal1741534/website/dist/index.html
  1. 在部署阶段,我执行以下命令,但更改后的index.html文件没有上传到s3存储桶,也没有显示在部署的网页中。 Cloudfront 缓存会在部署时自动清除。
script:
    - cdk bootstrap
    - cdk deploy --require-approval never

用于存储桶部署的CDK代码如下:

new BucketDeployment(this, "BucketDeployment", {
  destinationBucket: bucket,
  sources: [Source.asset("/builds/personal1741534/website/dist")],
  distribution,
  distributionPaths: ["/*"],
});

我期望在 gitlab 管道的构建步骤中更新的 index.html 文件将部署到 s3 并在网页中可见。

amazon-s3 gitlab-ci amazon-cloudfront aws-cdk
1个回答
0
投票

默认情况下,GitLab 中不会保留作业中的文件更改。因此更改作业中的文件不会影响任何其他作业中的文件。

要保留作业的输出,请在作业中使用

artifacts

artifacts:
    - paths:
        - /builds/

默认情况下,后续阶段的所有作业都将下载这些工件。

© www.soinside.com 2019 - 2024. All rights reserved.