I am trying to set up a CI/CD for my GitHub repo using CodePipeline. I have set up all stages:
In the Source stage, the action provider is GitHub. It links my repository. The entire code pipeline is able to be triggered from a git push
. It outputs SourceArtifact
.
In the Build stage, I am using AWS Commands as the action provider. My command is: zip -r project.zip ./project
. The output artifact is BuildArtifact
with the file project.zip
.
In the Deploy stage, the action provider is S3 and input artifact is BuildArtifact
. I provide my bucket name and check the box that says: Extract files before deploy
.
After the above configuration, my AWS CodePipeline does technically work. I can push to my repo and trigger the pipeline to execute. The pipeline does successfully execute and uploads the file project.zip
to my S3 bucket. However, I need it to extract the zip file before deployment which is what I thought should happen. I have it checked that it extracts the files before deployment but it's just uploading the entire zip file to the S3 bucket.
I have not yet found a solution to this online. I tried using CodeBuild for the Build stage with a buildspec.yml
file. however, I'm getting errors that don't seem to make sense to me like:
Unsupported field "on-failure" in buildspec
and
DOWNLOAD_SOURCE
Failed
CLIENT_ERROR: git fetch failed with exit status 128 for source a1fa55c3_1918_4f54_86e3_59175f50f802
This is the buildspec.yml
I was using:
version: 0.2
phases:
build:
commands:
- zip -r project.zip ./project
artifacts:
files:
- project.zip
So I'm not really sure what is the proper configuration at this point for my pipeline.
The workaround for this was to just have the Build stage of the pipeline perform some meaningless action (like an ls
). In the Deploy stage, I directly used the output of the Source stage.
This isn't the cleanest method, but it works.