Skip to content

Commit

Permalink
chore: add buildspec for environment pipelines (#3717)
Browse files Browse the repository at this point in the history
Related #3522

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
  • Loading branch information
efekarakus authored Jul 6, 2022
1 parent e561172 commit 14c6621
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions internal/pkg/template/templates/cicd/env/buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Buildspec runs in the build stage of your environment pipeline to generate the environment CloudFormation stack config.
version: 0.2
phases:
install:
runtime-versions:
ruby: 2.6
commands:
- echo "cd into $CODEBUILD_SRC_DIR"
- cd $CODEBUILD_SRC_DIR
# Download the copilot linux binary. You can update this version.
- wget -q {{.BinaryS3BucketPath}}/copilot-linux-{{.Version}}
- mv ./copilot-linux-{{.Version}} ./copilot-linux
- chmod +x ./copilot-linux
build:
commands:
- echo "Run your tests"
# - make test
post_build:
commands:
- ls -l
- export COLOR="false"
- export CI="true"
- pipeline=$(cat $CODEBUILD_SRC_DIR/{{.ManifestPath}} | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))')
- stages=$(echo $pipeline | jq -r '.stages[].name')
# Generate the cloudformation templates.
- >
for env in $stages; do
./copilot-linux env package -n $env --output-dir './infrastructure' --upload-assets;
if [ $? -ne 0 ]; then
echo "Cloudformation stack and config files were not generated. Please check build logs to see if there was a manifest validation error." 1>&2;
exit 1;
fi
done;
- ls -lah ./infrastructure
artifacts:
files:
- "infrastructure/*"

0 comments on commit 14c6621

Please sign in to comment.