Skip to content

Commit

Permalink
automate codedeploy deployments after build
Browse files Browse the repository at this point in the history
  • Loading branch information
fideloper committed Sep 10, 2021
1 parent 9359407 commit cb61751
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion buildspec.yml
Expand Up @@ -20,4 +20,4 @@ phases:
- ./scripts/build.sh staging
post_build:
commands:
- echo "todo -> Kick off a deployment"
- ./scripts/deploy.sh staging
5 changes: 4 additions & 1 deletion scripts/after_install.sh
Expand Up @@ -25,4 +25,7 @@ fi
# Start supervisor jobs (if supervisor is used)
if [[ "$DEPLOYMENT_GROUP_NAME" == *"queue"* ]]; then
supervisorctl start all
fi
fi

# Optionally, depending on your needs
# sudo -u cloudcasts php artisan migrate --force
2 changes: 1 addition & 1 deletion scripts/build.sh
Expand Up @@ -11,4 +11,4 @@ zip -qur builds/cloudcasts.zip vendor
zip -qur builds/cloudcasts.zip public

# Upload artifact to s3
aws s3 cp builds/cloudcasts.zip s3://cloudcasts-$1-artifacts/$CODEBUILD_RESOLVED_SOURCE_VERSION.zip
aws s3 cp builds/cloudcasts.zip s3://cloudcasts-$1-artifacts/$CODEBUILD_RESOLVED_SOURCE_VERSION.zip
15 changes: 15 additions & 0 deletions scripts/deploy.sh
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# Deploy queue servers
aws --region us-east-2 deploy create-deployment \
--application-name cloudcasts-$1-deploy-app \
--deployment-group-name "cloudcasts-$1-queue-deploy-group" \
--description "Deploying trigger $CODEBUILD_WEBHOOK_TRIGGER" \
--s3-location "bucket=cloudcasts-$1-artifacts,bundleType=zip,key=$CODEBUILD_RESOLVED_SOURCE_VERSION.zip"

# Deploy web servers
aws --region us-east-2 deploy create-deployment \
--application-name cloudcasts-$1-deploy-app \
--deployment-group-name "cloudcasts-$1-http-deploy-group" \
--description "Deploying tag $CODEBUILD_WEBHOOK_TRIGGER" \
--s3-location "bucket=cloudcasts-$1-artifacts,bundleType=zip,key=$CODEBUILD_RESOLVED_SOURCE_VERSION.zip"

0 comments on commit cb61751

Please sign in to comment.