-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM amazon/aws-cli | ||
|
||
ADD . / | ||
|
||
ENTRYPOINT ["bash", "/script.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Peter Ukonu | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: 'Deploy Web App' | ||
description: 'Deploys a webapp to an s3 bucket and then invalidates cloudfront entry' | ||
author: 'Peter Ukonu' | ||
branding: | ||
color: 'blue' | ||
inputs: | ||
build_path: | ||
description: "The build path to deploy to s3" | ||
required: true | ||
bucket_name: | ||
description: "The AWS S3 bucket you will like to deployt to" | ||
required: true | ||
bucket_key: | ||
description: "The path of the folder you will to deploy to within the S3 bucket" | ||
required: true | ||
default: "/" | ||
distribution_invalidation_path: | ||
description: "The path in cloudfront to invalidate" | ||
required: false | ||
default: "/*" | ||
outputs: | ||
aws-deploy-output: | ||
description: 'A json output from AWS on the deployment' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.build_path }} | ||
- ${{ inputs.bucket_name }} | ||
- ${{ inputs.bucket_key }} | ||
- ${{ inputs.distribution_invalidation_path }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash -l | ||
|
||
set -e | ||
|
||
# check configuration | ||
|
||
err=0 | ||
|
||
build_path=$1 | ||
bucket_name=$2 | ||
bucket_key=$3 | ||
distribution_invalidation_path=$4 | ||
aws_region=AWS_REGION | ||
|
||
ls -l $build_path | ||
|
||
if [ -z "$AWS_ACCESS_KEY_ID" ]; then | ||
echo "AWS_ACCESS_KEY was not found. Set this in your github secrets" | ||
err=1 | ||
fi | ||
|
||
if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then | ||
echo "AWS_SECRET_ACCESS_KEY was not founde. Set this in your github secrets" | ||
err=1 | ||
fi | ||
|
||
if [ -z "$aws_region" ]; then | ||
echo "Specify an AWS region" | ||
err=1 | ||
fi | ||
|
||
if [ -z "$bucket_name" ]; then | ||
echo "Specify a bucket you will like to deploy to" | ||
err=1 | ||
fi | ||
|
||
if [ $err -eq 1 ]; then | ||
exit 1 | ||
fi | ||
|
||
output="AWS OUTPUT" | ||
echo "::set-output name=aws-deploy-output::$output" | ||
|
||
aws s3 cp $build_path s3://$bucket_name/$bucket_key --recursive | ||
|
||
if [ -z "$DISTRIBUTION_ID" ]; then | ||
echo "Skipping cloudfront invalidation..." | ||
else | ||
|
||
if [ -z "$distribution_invalidation_path" ]; then | ||
echo "Specify the invalidation path. e.g. /* or /production/*" | ||
exit 1 | ||
fi | ||
|
||
echo "Invalidating cloudfront..." | ||
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "$distribution_invalidation_path" | ||
fi |