Reputation: 394
I am trying to configure a CodePipeline on AWS that it takes my Nuxt website on Github, run the command npm run generate
to generate the static website then upload the dist
folder on an S3 bucket.
Here what my buildspec.yml
it looks like:
version: 0.2
phases:
install:
commands:
- npm install
build:
commands:
- npm run generate
post_build:
commands:
- aws s3 sync dist $S3_BUCKET
The error I get is: The user-provided path dist does not exist.
Is anyone know how to correct this? I read a lot about artefacts but I never use them before…
Thanks in advance,
Upvotes: 3
Views: 5326
Reputation: 191
You can use artifacts to upload dist folder to s3. I will suggest not to use post build command to achieve this because the post build command runs even when the build is failed, this is the known limitation of codebuild. Just replace your buildspec with the following.
version: 0.2
phases:
install:
commands:
- npm install
build:
commands:
- npm run generate
artifacts:
files:
- '**/*'
base-directory: 'dist'
'**/*' means it will upload all the files and folder under the base directory "dist". You need to mention your bucket name in your aws console ( browser).
Also make sure that your codebuild IAM role has sufficient permission to access your bucket.
Upvotes: 8