Repository navigation
93 lines (75 loc) · 2.48 KB
/
Copy pathdeploy-public-api-lambda.yml
File metadata and controls
93 lines (75 loc) · 2.48 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Deploy public-api Lambda
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'backend/**'
- '.github/workflows/deploy-public-api-lambda.yml'
permissions:
contents: read
id-token: write
concurrency:
group: public-api-lambda-${{ github.ref }}
cancel-in-progress: true
env:
AWS_REGION: ap-northeast-2
LAMBDA_FUNCTION_NAME: ${{ vars.PUBLIC_API_LAMBDA_FUNCTION_NAME || 'mwt-public-api' }}
LAMBDA_ZIP_PATH: backend/target/lambda/public-api-arm64.zip
jobs:
deploy:
name: Build and deploy public-api
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-gnu
- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.2
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: backend
- name: Install cargo-zigbuild
run: |
if ! command -v cargo-zigbuild >/dev/null 2>&1; then
cargo install cargo-zigbuild --locked
fi
- name: Check Rust formatting
working-directory: backend
run: cargo fmt --all --check
- name: Test backend
working-directory: backend
run: cargo test
- name: Package public-api for Lambda ARM64
run: bash backend/scripts/package-public-api.sh
- name: Upload Lambda package artifact
uses: actions/upload-artifact@v4
with:
name: public-api-arm64
path: ${{ env.LAMBDA_ZIP_PATH }}
if-no-files-found: error
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6.1.0
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- name: Deploy Lambda code
run: |
aws lambda update-function-code \
--function-name "$LAMBDA_FUNCTION_NAME" \
--zip-file "fileb://$LAMBDA_ZIP_PATH"
aws lambda wait function-updated \
--function-name "$LAMBDA_FUNCTION_NAME"
- name: Show Lambda deployment summary
run: |
aws lambda get-function-configuration \
--function-name "$LAMBDA_FUNCTION_NAME" \
--query '{FunctionName:FunctionName,Runtime:Runtime,Architectures:Architectures,LastModified:LastModified,State:State}' \
--output table