I have a aws s3 + cloudfront webpage deployed using CDK via gitlab pipeline. (code repo is here : https://github.com/ruwanindika/website)
Gitlab stages are "build" --> "deploy"
script:
- sed -i "s/%%VERSION%%/$CI_COMMIT_SHORT_SHA/" /builds/personal1741534/website/dist/index.html
script:
- cdk bootstrap
- cdk deploy --require-approval never
CDK code for bucket deployment is below:
new BucketDeployment(this, "BucketDeployment", {
destinationBucket: bucket,
sources: [Source.asset("/builds/personal1741534/website/dist")],
distribution,
distributionPaths: ["/*"],
});
I expected the index.html file which was updated in build step of the gitlab pipeline will be deployed to the s3 and be visible in the webpage.
File changes in jobs are not persisted by default in GitLab. So changing a file in a job will not affect the files in any other job.
To persist a job's output, use the artifacts
key in the job:
artifacts:
- paths:
- /builds/
By default, all jobs in subsequent stages will download these artifacts.