-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(action-aws): add lambda-deploy action
- Loading branch information
1 parent
d322bc3
commit 3f7fe35
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# AWS: lambda-deploy | ||
|
||
## Behavior | ||
|
||
Download specified artifact. | ||
Connect to AWS. | ||
Update the lambda code and publish a new version | ||
|
||
## Usage | ||
|
||
```yaml | ||
jobs: | ||
deploy-lambda: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout Code" | ||
uses: "actions/checkout@v2" | ||
|
||
- name: "Deploy" | ||
uses: "meero-com/github-actions-shared-workflows/actions/aws/lambda-deploy@main" | ||
with: | ||
artifact_name: image-uri | ||
artifact_filename: image-uri.txt | ||
AWS_ACCESS_KEY_ID: ${{ secrets.NP_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.NP_AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
LAMBDA_FUNCTION_NAME: my-wonderful-lambda | ||
``` | ||
Beware of using a `@ref` (`@main` in the example above) which suits your stability requirements in your workflow: | ||
|
||
* Use `@main` if you always want to use the latest version of the workflow. | ||
* Use `@<tag>` if you wan to use a specific frozen version of the workflow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: "Deploy Lambda" | ||
description: "Deploy the Lambda Function" | ||
|
||
inputs: | ||
AWS_ACCESS_KEY_ID: | ||
description: "Aws access key" | ||
required: true | ||
AWS_SECRET_ACCESS_KEY: | ||
description: "AWS secret" | ||
required: true | ||
AWS_REGION: | ||
description: "AWS region" | ||
required: true | ||
LAMBDA_FUNCTION_NAME: | ||
description: "Lambda function name" | ||
required: true | ||
artifact_name: | ||
description: "name of Image artifact (container) to deploy" | ||
required: true | ||
artifact_filename: | ||
description: "filename of Image artifact (container) to deploy" | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Fetch Image URI artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ${{ inputs.artifact_name }} | ||
|
||
- name: Set variable image from artifact (image URI) | ||
shell: bash | ||
id: vars | ||
run: echo "image=$(cat ${{ inputs.artifact_filename }})" >> $GITHUB_OUTPUT | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ inputs.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ inputs.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ inputs.AWS_REGION }} | ||
|
||
- name: Update the Lambda code (new Docker image) | ||
shell: bash | ||
env: | ||
IMAGE_URI: ${{ steps.vars.outputs.image }} | ||
LAMBDA_FUNCTION_NAME: ${{ inputs.LAMBDA_FUNCTION_NAME }} | ||
run: | | ||
aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME --image-uri $IMAGE_URI | ||
aws lambda wait function-updated --function-name $LAMBDA_FUNCTION_NAME | ||
result=$(aws lambda publish-version --function-name $LAMBDA_FUNCTION_NAME) | ||
version=$(echo ${result}| jq -r .Version) | ||
echo "Deployed version ${version} of the lambda $LAMBDA_FUNCTION_NAME" |