Created
January 11, 2021 12:51
-
-
Save ycd/94b6e47368498568c22b13024b6b3795 to your computer and use it in GitHub Desktop.
AWS Lambda auto deployment pipeline for GO (Golang)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- test | |
- deploy | |
test: | |
stage: test | |
image: golang:1.15-alpine | |
script: | |
- apk add build-base | |
- go test $(go list ./... | grep -v /vendor/) | |
only: | |
- master | |
- merge_requests | |
tags: | |
- gitlab-runner | |
deploy: | |
stage: deploy | |
image: golang:1.15-alpine | |
before_script: | |
- apk update && apk add zip | |
script: | |
- | | |
apk add --no-cache \ | |
python3 \ | |
py3-pip \ | |
&& pip3 install --upgrade pip \ | |
&& pip3 install \ | |
awscli \ | |
&& rm -rf /var/cache/apk/* | |
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main . | |
- zip <PACKAGE_NAME> main | |
- | | |
aws lambda update-function-code \ | |
--function-name <PACKAGE_NAME> \ | |
--zip-file fileb://<PACKAGE_NAME>.zip \ | |
only: | |
- master | |
tags: | |
- gitlab-runner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment