Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -32,7 +24,5 @@ runs:
post-if: always()
args:
- ${{ inputs.stack-id }}
- ${{ inputs.add-branch-suffix }}
- ${{ inputs.parameters }}
- ${{ inputs.app-file }}
- ${{ inputs.bootstrap }}
26 changes: 4 additions & 22 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
22 changes: 3 additions & 19 deletions destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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