diff --git a/action.yaml b/action.yaml index 1bdfd00..195ab9a 100644 --- a/action.yaml +++ b/action.yaml @@ -21,9 +21,9 @@ inputs: description: "The function name/ARN to update" required: true alias: - description: "The alias to place on the deployed version (default: Live)" + description: "The alias to place on the deployed version (default: Live). Alias have to pre-exist" default: "Live" - required: false + required: true runs: using: docker image: Dockerfile \ No newline at end of file diff --git a/deploy.sh b/deploy.sh index 6606c60..617c732 100644 --- a/deploy.sh +++ b/deploy.sh @@ -7,12 +7,11 @@ export PACKAGE_S3_KEY=$INPUT_PACKAGE_S3_KEY export FUNCTION_NAME=$INPUT_FUNCTION_NAME export ALIAS=$INPUT_ALIAS - - echo "Getting the current version associated to the alias + CodeSha256" CURRENT_FUNCTION_VERSION=$(aws lambda get-alias --function-name $FUNCTION_NAME --name $ALIAS | jq '.FunctionVersion' | sed 's/"//g' ) CURRENT_FUNCTION_SHA=$(aws lambda get-function-configuration --function-name $FUNCTION_NAME \ --qualifier $CURRENT_FUNCTION_VERSION --query "CodeSha256") +echo "Current SHA256: ${CURRENT_FUNCTION_SHA}" echo "Updating the function code" UPDATE_RESULT=$(aws lambda update-function-code --function-name $FUNCTION_NAME --s3-bucket $PACKAGE_S3_BUCKET --s3-key $PACKAGE_S3_KEY) UPDATE_STATUS=$(echo $UPDATE_RESULT | jq '.LastUpdateStatus' | sed 's/"//g') @@ -21,6 +20,7 @@ if [ $UPDATE_STATUS != "Successful" ]; then exit 1 fi FUNCTION_SHA=$(echo $UPDATE_RESULT | jq '.CodeSha256') +echo "New SHA256: ${FUNCTION_SHA}" if [[ $CURRENT_FUNCTION_SHA == $FUNCTION_SHA ]]; then echo "Same function code, skipping" exit 0 diff --git a/test.sh b/test.sh deleted file mode 100644 index 70c9e65..0000000 --- a/test.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -export APP_NAME=111 -export DEPLOYMENT_GROUP=222 -export PACKAGE_S3_BUCKET=333 -export PACKAGE_S3_KEY=444 -export FUNCTION_NAME=555 -export ALIAS=666 - -echo "Updating the function code" -echo "Publishing a new version of the function and getting the new version id" -echo "Getting the version_id currently associated with the given alias" -FUNCTION_ALIAS_VERSION=777 -FUNCTION_VERSION=888 - -echo "Create AppSpec.json" -FILE_CONTENT="{'version': '0.0', -'Resources': [{ - '${FUNCTION_NAME}': { - 'Type': 'AWS::Lambda::Function', - 'Properties': { - 'Name': '${FUNCTION_NAME}', - 'Alias': '${ALIAS}', - 'CurrentVersion': '${FUNCTION_VERSION}', - 'TargetVersion': '${FUNCTION_ALIAS_VERSION}' - } - } -}], -'Hooks': [] -}" -echo $FILE_CONTENT | sed "s/'/\"/g" -echo $FILE_CONTENT > AppSpec.json