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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Bug fixes go here

## [1.2.0] - 2024-06-04

### :sparkles: Added

- Adds support for passing custom app path through the `app-file` input
- Adds cdk-nag and identity pool alpha as dependencies

### :pencil2: Changed

- Bumps CDK dependency versions

## [1.1.0] - 2023-10-10

### :sparkles: Added
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM node:20-alpine3.17

RUN npm install -g aws-cdk@2.99.1
RUN npm install -g aws-cdk@2.144.0
RUN apk add --no-cache \
py3-pip \
git \
jq
RUN pip3 install \
aws-cdk-lib==2.93.0 \
constructs==10.2.70
aws-cdk.aws-cognito-identitypool-alpha==2.144.0a0 \
aws-cdk-lib==2.144.0 \
constructs==10.3.0 \
cdk-nag==2.28.130

COPY ./deploy.sh /deploy.sh
COPY ./destroy.sh /destroy.sh
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Currently, the action supports:
| add-branch-suffix | boolean | no | false | Appends a commit hash to the Stack ID |
| 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 |

## Action Outputs

Expand Down Expand Up @@ -45,6 +46,7 @@ jobs:
id: deploy
uses: rivelinrobotics/deploy-aws-cdk-stack@v1
with:
app-file: ./aws/app.py
stack-id: MyCustomStack
add-branch-suffix: true
ephemeral: true
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ inputs:
description: CfnParameters of the form `k1=v1 k2=v2 ...`
required: false
default: ""
app-file:
description: The path to the CDK app file
required: false
default: "app.py"
runs:
using: docker
image: Dockerfile
Expand All @@ -26,3 +30,4 @@ runs:
- ${{ inputs.stack-id }}
- ${{ inputs.add-branch-suffix }}
- ${{ inputs.parameters }}
- ${{ inputs.app-file }}
11 changes: 6 additions & 5 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
STACK_ID=${1}
ADD_STACK_SUFFIX=${2}
PARAMETER_STRING=${3}
APP_FILE=${4}
CFN_PARAMETERS=${PARAMETER_STRING}
FULL_STACK_ID=${STACK_ID}
UNSCOPED_APP=app.py.tmp
UNSCOPED_APP=${APP_FILE}.tmp
OUTPUT_FILE=.cdk-outputs.json
CDK_PROJECT=/github/workspace

Expand All @@ -14,8 +15,8 @@ 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.py ${UNSCOPED_APP}
sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > app.py
mv ${APP_FILE} ${UNSCOPED_APP}
sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > ${APP_FILE}
fi

for PARAMETER in ${PARAMETER_STRING}; do
Expand All @@ -33,8 +34,8 @@ chmod a+rw -R cdk.out
chmod a+rw -R ${OUTPUT_FILE}

if [ ${ADD_STACK_SUFFIX} == "true" ]; then
rm app.py
mv ${UNSCOPED_APP} app.py
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
11 changes: 6 additions & 5 deletions destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

STACK_ID=${1}
ADD_STACK_SUFFIX=${2}
APP_FILE=${4}
FULL_STACK_ID=${STACK_ID}
UNSCOPED_APP=app.py.tmp
UNSCOPED_APP=${APP_FILE}.tmp
CDK_PROJECT=/github/workspace

cd ${CDK_PROJECT}
Expand All @@ -13,15 +14,15 @@ 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.py ${UNSCOPED_APP}
sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > app.py
mv ${APP_FILE} ${UNSCOPED_APP}
sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > ${APP_FILE}
fi

cdk destroy --force --exclusively ${FULL_STACK_ID}

if [ ${ADD_STACK_SUFFIX} == "true" ]; then
rm app.py
mv ${UNSCOPED_APP} app.py
rm ${APP_FILE}
mv ${UNSCOPED_APP} ${APP_FILE}
fi

else
Expand Down