-
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
0 parents
commit a27308d
Showing
6 changed files
with
191 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,2 @@ | ||
# IDE | ||
.vscode |
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,19 @@ | ||
FROM ubuntu | ||
|
||
LABEL version="1.0.0" | ||
|
||
LABEL com.github.actions.name="CloudFormation Deploy Action for AWS" | ||
LABEL com.github.actions.description="Deploy AWS CloudFormation Stack using AWS CLI" | ||
LABEL com.github.actions.icon="upload-cloud" | ||
LABEL com.github.actions.color="green" | ||
|
||
LABEL repository="https://github.com/MaximilianoBz/actions-cloudformation" | ||
LABEL homepage="https://github.com/MaximilianoBz/actions-cloudformation" | ||
LABEL maintainer="Maximiliano Baez <[email protected]>" | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && apt-get install -y awscli | ||
|
||
ADD entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Bo-Yi Wu | ||
|
||
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,64 @@ | ||
# CloudFormation Deploy Action with AWS CLI | ||
|
||
This action deploys AWS CloudFormation Stacks through yml files. | ||
|
||
## Usage | ||
|
||
```yml | ||
name: "Deploy CloudFormation Stack to AWS" | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: maximilianobz/[email protected] | ||
env: | ||
TEMPLATE: 'template.yml' | ||
AWS_STACK_NAME: 'my-stack' | ||
AWS_REGION: 'us-east-1' | ||
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} | ||
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} | ||
AWS_DEPLOY_BUCKET: ${{secrets.AWS_DEPLOY_BUCKET}} | ||
``` | ||
### Environment Variables | ||
* `TEMPLATE` - [Optional]. YML file containing CloudFormation Stack. | ||
* Type: `string` | ||
* Default: `template.yml` | ||
* `TEMPLATEOUTPUT` - [Optional]. YML file containing SAM template. | ||
* Type: `string` | ||
* `CAPABILITIES` - [Optional]. AWS Stack Capabilites. | ||
* Type: `string` | ||
* Default: `CAPABILITY_IAM` | ||
* `AWS_STACK_NAME` - [**Required**]. The Stack name that is going to be published. | ||
* Type: `string` | ||
* `AWS_REGION` - [**Required**]. AWS Region where to deploy the CloudFormation Stack. | ||
* Type: `string` | ||
* `AWS_ACCESS_KEY_ID` - [**Required**]. AWS Access Key Id. | ||
* Type: `string` | ||
* `AWS_SECRET_ACCESS_KEY` - [**Required**]. AWS Secret Access Key. | ||
* Type: `string` | ||
* `AWS_DEPLOY_BUCKET` - [**Required**]. AWS S3 Bucket where the Stack package is going to be stored. | ||
* Type: `string` | ||
* `AWS_BUCKET_PREFIX` - [Optional]. S3 Bucket's folder where to upload the package. | ||
* Type: `string` | ||
* `FORCE_UPLOAD` - [Optional]. Whether to override existing packages in case they are an exact match. | ||
* Type: `boolean` | ||
* `USE_JSON` - [Optional]. Whether to use JSON instead of YML as the output template format. | ||
* Type: `boolean` | ||
* `PARAMETER_OVERRIDES` - [Optional]. Parameters to input in the template. | ||
* Type: `string | list[string]` | ||
* Syntax: `AliasName=prod` `AliasName=prod ApiUrl=https://api.com/api/v1` | ||
|
||
|
||
### License | ||
|
||
The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). | ||
|
||
Original work by "Matheus Genteluci <[email protected]>" |
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,8 @@ | ||
name: 'CloudFormation Deploy Action for AWS' | ||
description: 'Deploy AWS CloudFormation Stack using AWS CLI' | ||
branding: | ||
icon: 'upload-cloud' | ||
color: 'green' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
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,77 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [[ -z "$TEMPLATE" ]]; then | ||
echo "Empty template specified. Looking for template.yml..." | ||
|
||
if [[ ! -f "template.yml" ]]; then | ||
echo template.yml not found | ||
exit 1 | ||
fi | ||
|
||
TEMPLATE="template.yml" | ||
fi | ||
|
||
if [[ -z "$TEMPLATEOUTPUT" ]]; then | ||
echo "Template output file" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$AWS_STACK_NAME" ]]; then | ||
echo AWS Stack Name invalid | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$AWS_ACCESS_KEY_ID" ]]; then | ||
echo AWS Access Key ID invalid | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$AWS_SECRET_ACCESS_KEY" ]]; then | ||
echo AWS Secret Access Key invalid | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$AWS_REGION" ]]; then | ||
echo AWS Region invalid | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$AWS_DEPLOY_BUCKET" ]]; then | ||
echo AWS Deploy Bucket invalid | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -z "$AWS_BUCKET_PREFIX" ]]; then | ||
AWS_BUCKET_PREFIX="--s3-prefix ${AWS_BUCKET_PREFIX}" | ||
fi | ||
|
||
if [[ $FORCE_UPLOAD == true ]]; then | ||
FORCE_UPLOAD="--force-upload" | ||
fi | ||
|
||
if [[ $USE_JSON == true ]]; then | ||
USE_JSON="--use-json" | ||
fi | ||
|
||
if [[ -z "$CAPABILITIES" ]]; then | ||
CAPABILITIES="--capabilities CAPABILITY_IAM" | ||
else | ||
CAPABILITIES="--capabilities $CAPABILITIES" | ||
fi | ||
|
||
if [[ ! -z "$PARAMETER_OVERRIDES" ]]; then | ||
PARAMETER_OVERRIDES="--parameter-overrides $PARAMETER_OVERRIDES" | ||
fi | ||
|
||
aws configure --profile cloudformation-action <<-EOF | ||
${AWS_ACCESS_KEY_ID} | ||
${AWS_SECRET_ACCESS_KEY} | ||
${AWS_REGION} | ||
text | ||
EOF | ||
|
||
aws cloudformation package --profile cloudformation-action --template-file $TEMPLATE --output-template-file $TEMPLATEOUTPUT --s3-bucket $AWS_DEPLOY_BUCKET $AWS_BUCKET_PREFIX $FORCE_UPLOAD $USE_JSON | ||
aws cloudformation deploy --profile cloudformation-action --template-file aws $TEMPLATEOUTPUT --stack-name $AWS_STACK_NAME $CAPABILITIES $PARAMETER_OVERRIDES | ||
|