-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
65 lines (56 loc) · 2.31 KB
/
buildspec.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
63
64
65
version: 0.2
env:
shell: bash
git-credential-helper: yes
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_SERVER
- echo Logging in to Docker Hub
- aws s3 cp s3://resl-misc/.docker.key .docker.key
- docker login -u twoseventythree --password-stdin < .docker.key
- rm .docker.key
- aws s3 cp s3://resl-misc/.slack_token .slack_token
- aws s3 cp s3://resl-misc/.slack_signing_secret .slack_signing_secret
build:
commands:
- export GIT_TAG=${CODEBUILD_WEBHOOK_HEAD_REF#refs/tags/}
- echo $GIT_TAG
- |
if [[ $GIT_TAG =~ ^[v][0-9]+[.][0-9]+[.][0-9]+$ ]]; then
export IMAGE_URI=${IMAGE_URI_BASE}:${GIT_TAG}
echo Building Docker image as ${IMAGE_URI}...
docker build -t ${IMAGE_URI} lambdas/code_exec
echo Pushing Docker image...
docker push ${IMAGE_URI}
else
echo Cloning RESL repo to determine latest tag
git clone https://github.com/stripedpajamas/resl.git
cd resl
export LATEST_COMMIT=$(git rev-list --tags --max-count=1)
export LATEST_TAG=$(git describe --tags ${LATEST_COMMIT})
echo "Latest Tag is: ${LATEST_TAG}"
export IMAGE_URI=${IMAGE_URI_BASE}:${LATEST_TAG}
cd ..
fi
- cd lambdas/slack_listener
- go mod download
- GOOS=linux go build -o slack_listener *.go
- cd ../../
- mv lambdas/slack_listener/slack_listener ./
- cd lambdas/slack_responder
- go mod download
- GOOS=linux go build -o slack_responder *.go
- cd ../../
- mv lambdas/slack_responder/slack_responder ./
- aws cloudformation package --template-file template.yml --s3-bucket "resl-build-artifacts" --output-template-file outputtemplate.yml
- export SLACK_TOKEN=$(cat .slack_token)
- export SLACK_SIGNING_SECRET=$(cat .slack_signing_secret)
- echo Deploying project...
- |
aws cloudformation deploy \
--stack-name $PROJECT_NAME \
--template-file outputtemplate.yml \
--parameter-overrides ImageUri=${IMAGE_URI} SlackToken=${SLACK_TOKEN} SlackSigningSecret=${SLACK_SIGNING_SECRET} \
--capabilities CAPABILITY_IAM