Skip to content

Commit

Permalink
Add cd to aws lambda and fix docker build ci
Browse files Browse the repository at this point in the history
  • Loading branch information
vgjm committed Jul 5, 2024
1 parent 8f44912 commit 900009b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
File renamed without changes.
35 changes: 35 additions & 0 deletions .github/workflows/lambda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy to lambda
on:
push:
tags: ['*']
jobs:

deploy_zip:
name: deploy lambda function
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.22]
steps:
- name: checkout source code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Build binary
run: |
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o bootstrap -tags lambda.norpc main.go && zip linebotFunction.zip bootstrap
- name: default deploy
uses: appleboy/[email protected]
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_REGION }}
function_name: linebotFunction
zip_file: linebotFunction.zip
memory_size: 256
timeout: 30
handler: bootstrap
role: ${{ secrets.AWS_LAMBDA_ROLE }}
runtime: provided.al2023
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN go build -o /bin/app
RUN go build -C cmd -o /bin/app

FROM ubuntu:latest
RUN apt-get update
Expand Down
24 changes: 24 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"context"
"log"
"net/http"

"github.com/vgjm/linebot/linebot"
)

func main() {
ctx := context.Background()

lb, err := linebot.New(ctx)
if err != nil {
log.Fatal(err)
}
defer lb.Close()

http.HandleFunc("/", lb.Callback)

http.ListenAndServe(":5000", nil)

}

0 comments on commit 900009b

Please sign in to comment.