diff --git a/CHANGELOG.md b/CHANGELOG.md index a184266..55586be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bug fixes go here -## [1.3.9] - 2024-06-04 +## [2.0.0] - 2024-06-10 + +### :pencil2: Changed + +- Changes `stack-id` to `stack-pattern` + +### :no_entry_sign: Removed + + - Removes `bootstrap` input + - Removes `add-branch-suffix` argument in favour of using `BranchScopedStack` + +## [1.3.0] - 2024-06-04 ### :sparkles: Added diff --git a/README.md b/README.md index 153ecd9..92a180f 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,10 @@ Currently, the action supports: | *Input* | *Type* | *Required* | *Default* | *Description* | |-------------------|---------|------------|-----------|---------------------------------------------| -| stack-id | string | yes | | The ID of the Stack to Deploy | -| add-branch-suffix | boolean | no | false | Appends a commit hash to the Stack ID | +| stack-pattern | string | yes | | Regex matching the ID of the Stack to Deploy| | ephemeral | boolean | no | false | Destroys the Stack at the end of the Job | | parameters | string | no | "" | CfnParameters of the form `k1=v1 k2=v2 ...` | | app-file | string | no | app.py | Path to the CDK App file | -| bootstrap | boolean | no | false | Whether to bootstrap the AWS account | ## Action Outputs @@ -49,8 +47,6 @@ jobs: with: app-file: ./aws/app.py stack-id: MyCustomStack - add-branch-suffix: true - bootstrap: true ephemeral: true parameters: > Parameter1=Value1 diff --git a/action.yml b/action.yml index 9265b42..ece35d2 100644 --- a/action.yml +++ b/action.yml @@ -1,13 +1,9 @@ name: rivelinrobotics/deploy-aws-cdk-stack description: Deploys a Stack to AWS using the Cloud Development Kit (CDK) inputs: - stack-id: - description: The ID of the Stack to deploy + stack-pattern: + description: A pattern matching the ID of the Stack to deploy required: true - add-branch-suffix: - description: Adds a short commit hash to the Stack ID - required: false - default: false ephemeral: description: Destroys the Stack at the end of the workflow required: false @@ -20,10 +16,6 @@ inputs: description: The path to the CDK app file required: false default: "app.py" - bootstrap: - decription: Whether or not to bootstrap the AWS account before deploying - required: false - default: false runs: using: docker image: Dockerfile @@ -32,7 +24,5 @@ runs: post-if: always() args: - ${{ inputs.stack-id }} - - ${{ inputs.add-branch-suffix }} - ${{ inputs.parameters }} - ${{ inputs.app-file }} - - ${{ inputs.bootstrap }} diff --git a/deploy.sh b/deploy.sh index 5b16792..b9241c0 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,32 +1,20 @@ #!/bin/sh -l STACK_ID=${1} -ADD_STACK_SUFFIX=${2} -PARAMETER_STRING=${3} -APP_FILE=${4} -BOOTSTRAP=${5} +PARAMETER_STRING=${2} +APP_FILE=${3} + CFN_PARAMETERS=${PARAMETER_STRING} -FULL_STACK_ID=${STACK_ID} -UNSCOPED_APP=${APP_FILE}.tmp OUTPUT_FILE=.cdk-outputs.json CDK_PROJECT=/github/workspace cd ${CDK_PROJECT} -if [ ${ADD_STACK_SUFFIX} == "true" ]; then - git config --global --add safe.directory ${CDK_PROJECT} - FULL_STACK_ID=${STACK_ID}$(git rev-parse --short HEAD) - mv ${APP_FILE} ${UNSCOPED_APP} - sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > ${APP_FILE} -fi - for PARAMETER in ${PARAMETER_STRING}; do CFN_PARAMETERS=$(echo ${CFN_PARAMETERS} | sed "s/${PARAMETER}/--parameters ${PARAMETER}/g") done -if [ ${BOOTSTRAP} == "true" ]; then - cdk bootstrap --require-approval never -fi +FULL_STACK_ID=$(cdk list | grep ${STACK_ID}) cdk deploy \ --require-approval never \ @@ -37,10 +25,4 @@ cdk deploy \ chmod a+rw -R cdk.out chmod a+rw -R ${OUTPUT_FILE} - -if [ ${ADD_STACK_SUFFIX} == "true" ]; then - rm ${APP_FILE} - mv ${UNSCOPED_APP} ${APP_FILE} -fi - echo "stack-output=$(cat ${OUTPUT_FILE} | jq -c --arg ID ${FULL_STACK_ID} '.[$ID]')" >> $GITHUB_OUTPUT diff --git a/destroy.sh b/destroy.sh index f9d99b2..66d5dac 100755 --- a/destroy.sh +++ b/destroy.sh @@ -2,31 +2,15 @@ STACK_ID=${1} ADD_STACK_SUFFIX=${2} -APP_FILE=${4} -FULL_STACK_ID=${STACK_ID} -UNSCOPED_APP=${APP_FILE}.tmp +APP_FILE=${3} + CDK_PROJECT=/github/workspace cd ${CDK_PROJECT} if [ ${INPUT_EPHEMERAL} == "true" ]; then - - if [ ${ADD_STACK_SUFFIX} == "true" ]; then - git config --global --add safe.directory ${CDK_PROJECT} - FULL_STACK_ID=${STACK_ID}$(git rev-parse --short HEAD) - mv ${APP_FILE} ${UNSCOPED_APP} - sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > ${APP_FILE} - fi - + FULL_STACK_ID=$(cdk list | grep ${STACK_ID}) cdk destroy --force --exclusively ${FULL_STACK_ID} - - if [ ${ADD_STACK_SUFFIX} == "true" ]; then - rm ${APP_FILE} - mv ${UNSCOPED_APP} ${APP_FILE} - fi - else - echo Skipping Stack teardown - fi \ No newline at end of file