Skip to content

Build and deploy lambda to AWS #38

Build and deploy lambda to AWS

Build and deploy lambda to AWS #38

name: Build and deploy lambda to AWS
on:
workflow_dispatch:
inputs:
runtime:
type: choice
description: 'What runtime to use?'
required: true
default: 'custom native-package'
options:
- 'custom native-package'
- 'custom assembly'
- 'java21 pure'
- 'java21 snapstart'
# push:
# branches: [main]
# paths:
# - '.github/workflows/buildAndDeployLambda.yaml'
# - 'scripts/deployLambda.sc'
# - '!**.test.scala'
# - '**.scala'
env:
AWS_CLIENT_DEBUG_MODE: ON
default-runtime: 'custom native-package'
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout
jobs:
buildAndDeployLambda:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: coursier/cache-action@v6
- uses: VirtusLab/scala-cli-setup@main
with:
jvm: adoptium:1.21
apps: scala scala-cli sbtn
power: true
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::047719648492:role/GithubActionRole
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: eu-central-1
unset-current-credentials: true
- name: Show changelog
run: echo "CHANGELOG=$(git log --pretty='%h %al %B' ${{ github.event.before }}..${{ github.sha }})" | tr -d "\n\r\'" | cut -c -256 >> "$GITHUB_ENV"
- name: Run the script (custom runtime with native-package)
if: ${{ (github.event_name == 'push' && env.default-runtime == 'custom native-package') || inputs.runtime == 'custom native-package' }}
run: ./scripts/buildAndDeployLambdaNativePackage.sh 64m '${{ env.CHANGELOG }}'
shell: bash
- name: Run the script (custom runtime with assembly.jar)
if: ${{ (github.event_name == 'push' && env.default-runtime == 'custom assembly') || inputs.runtime == 'custom assembly' }}
run: ./scripts/buildAndDeployLambdaAssembly.sh '${{ env.CHANGELOG }}' 'assembly'
shell: bash
- name: Run the script (java21 runtime without snapstart)
if: ${{ (github.event_name == 'push' && env.default-runtime == 'java21 pure') || inputs.runtime == 'java21 pure' }}
run: ./scripts/buildAndDeployLambdaAssembly.sh '${{ env.CHANGELOG }}' 'pure'
shell: bash
- name: Run the script (java21 runtime with snapstart)
if: ${{ (github.event_name == 'push' && env.default-runtime == 'java21 snapstart') || inputs.runtime == 'java21 snapstart' }}
run: ./scripts/buildAndDeployLambdaAssembly.sh '${{ env.CHANGELOG }}' 'snapstart'
shell: bash