From 14c662182875f0576ce7495f5bc500dee0857289 Mon Sep 17 00:00:00 2001 From: Efe Karakus Date: Wed, 6 Jul 2022 13:40:36 -0700 Subject: [PATCH] chore: add buildspec for environment pipelines (#3717) 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. --- .../template/templates/cicd/env/buildspec.yml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 internal/pkg/template/templates/cicd/env/buildspec.yml diff --git a/internal/pkg/template/templates/cicd/env/buildspec.yml b/internal/pkg/template/templates/cicd/env/buildspec.yml new file mode 100644 index 00000000000..8b6a8fa0faa --- /dev/null +++ b/internal/pkg/template/templates/cicd/env/buildspec.yml @@ -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/*"