Skip to content

Instantly share code, notes, and snippets.

@ycd
Created January 11, 2021 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ycd/94b6e47368498568c22b13024b6b3795 to your computer and use it in GitHub Desktop.
Save ycd/94b6e47368498568c22b13024b6b3795 to your computer and use it in GitHub Desktop.
AWS Lambda auto deployment pipeline for GO (Golang)
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