-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (50 loc) · 1.36 KB
/
github-ci.yml
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
name: Build and Deploy Lambda Function
on:
push:
branches:
- prod
jobs:
build:
name: Build Go Binary
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.18'
- name: Build Go binary
run: go build -o app ./cmd/main.go
- name: Ensure required Lambda dependencies
run: go mod vendor
- name: Zip binary with dependencies
run: zip -r app.zip app vendor
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: app
path: ./app.zip
deploy:
name: Deploy to AWS Lambda
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: app
path: .
- name: Install AWS CLI
run: |
sudo apt-get update
sudo apt-get install -y awscli
- name: Deploy to Lambda
run: |
aws lambda update-function-code \
--function-name blog-api-lambda \
--zip-file fileb://app.zip \
--region ap-northeast-1
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}