-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (58 loc) · 1.95 KB
/
lambda.yml
File metadata and controls
71 lines (58 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Lambda CI/CD
on:
push:
branches:
- '**'
paths:
- 'Backend/AeChatLambda/**'
- '.github/workflows/lambda.yml'
workflow_dispatch:
jobs:
build:
name: Build and Package
runs-on: ubuntu-latest
defaults:
run:
working-directory: Backend/AeChatLambda
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore
run: dotnet restore
- name: Install Amazon.Lambda.Tools
run: dotnet tool install -g Amazon.Lambda.Tools
- name: Add dotnet tools to PATH
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: Package Lambda
run: dotnet lambda package --configuration Release --framework net8.0 --output-package bin/Release/net8.0/package.zip
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: lambda-package
path: Backend/AeChatLambda/bin/Release/net8.0/package.zip
deploy:
name: Deploy Lambda
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && endsWith(github.ref, '/main')) }}
permissions:
id-token: write
contents: read
steps:
- name: Download package artifact
uses: actions/download-artifact@v4
with:
name: lambda-package
path: Backend/AeChatLambda/bin/Release/net8.0
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::687908690092:role/Ae.DirectChat
aws-region: eu-west-1
role-session-name: github-actions-lambda-deploy
- name: Update Lambda code
run: aws lambda update-function-code --function-name AeChat --zip-file fileb://Backend/AeChatLambda/bin/Release/net8.0/package.zip --publish