-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (56 loc) · 2.17 KB
/
BuildAndReleaseToS3.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
name: Build and Release Golang Lambda Function to S3
on:
workflow_call:
inputs:
lambda_function_name:
required: true
type: string
secrets:
BUCKET_LOCATION:
description: s3 uri for the bucket
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
build_lint_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Install linter
run: go install golang.org/x/lint/golint@latest
- name: Lint Project
run: golint ./...
- name: Build for S3
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -a -o main main.go
- name: Zip build
run: zip -r main.zip main
- name: Install AWS CLI
run: |
sudo apt-get install -y awscli
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Upload build to S3
run: aws s3 cp main.zip $BUCKET_LOCATION/${{github.sha}}/
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BUCKET_LOCATION: ${{secrets.BUCKET_LOCATION}}
- name: Update lambda with new build
run: |
aws lambda update-function-code \
--function-name ${{inputs.lambda_function_name}} \
--zip-file fileb://main.zip
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}