diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9310a5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# IDE +.vscode diff --git a/Dockerfile b/Dockerfile index b1a41ac..b09c9bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu -LABEL version="0.0.1" +LABEL version="1.0.0" LABEL com.github.actions.name="CloudFormation Deploy Action" LABEL com.github.actions.description="Deploy AWS CloudFormation Stack" diff --git a/README.md b/README.md index 3fc2cd3..c5139d6 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - uses: mgenteluci/cloudformation-deploy-action@v1.1.0 + - uses: mgenteluci/cloudformation-deploy-action@v1.2.0 env: TEMPLATE: 'template.yml' - CAPABILITIES: 'CAPABILITY_IAM' AWS_STACK_NAME: 'my-stack' AWS_REGION: 'us-east-1' AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} @@ -29,13 +28,28 @@ jobs: ### Environment Variables -* `TEMPLATE` - [Optional]. YML file containing CloudFormation Stack. Default to `template.yml`. -* `CAPABILITIES` - [Optional]. AWS Stack Capabilites. Default to `CAPABILITY_IAM`. +* `TEMPLATE` - [Optional]. YML file containing CloudFormation Stack. + * Type: `String` + * Default: `template.yml` +* `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` ### Examples diff --git a/entrypoint.sh b/entrypoint.sh index db5bd01..a070836 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,10 +3,10 @@ set -e if [[ -z "$TEMPLATE" ]]; then - echo Empty template specified. Searching template.yml... + echo "Empty template specified. Looking for template.yml..." if [[ ! -f "template.yml" ]]; then - echo default template.yml not found + echo template.yml not found exit 1 fi @@ -38,6 +38,18 @@ if [[ -z "$AWS_DEPLOY_BUCKET" ]]; then 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=CAPABILITY_IAM fi @@ -55,5 +67,5 @@ echo "[default] output = text region = $AWS_REGION" > ~/.aws/config -aws cloudformation package --template-file $TEMPLATE --output-template-file serverless-output.yaml --s3-bucket $AWS_DEPLOY_BUCKET +aws cloudformation package --template-file $TEMPLATE --output-template-file serverless-output.yaml --s3-bucket $AWS_DEPLOY_BUCKET $AWS_BUCKET_PREFIX $FORCE_UPLOAD $USE_JSON aws cloudformation deploy --template-file serverless-output.yaml --stack-name $AWS_STACK_NAME --capabilities $CAPABILITIES