-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuildspec.yaml
86 lines (67 loc) · 2.61 KB
/
buildspec.yaml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
version: 0.2
env:
git-credential-helper: yes
secrets-manager:
DEV_ACCESS_KEY_ID: "dev/user/codebuild:AWS_ACCESS_KEY_ID"
DEV_SECRET_ACCESS_KEY: "dev/user/codebuild:AWS_SECRET_ACCESS_KEY"
DEV_REGION: "dev/user/codebuild:AWS_REGION"
S3_BUCKET: "dev/user/codebuild:S3_BUCKET"
DOCKER_USERNAME: docker:username
DOCKER_PASSWORD: docker:password
variables:
CGO_ENABLED: "0"
GOOS: "linux"
GOARCH: "amd64"
proxy:
upload-artifacts: yes
logs: yes
phases:
install:
runtime-versions:
golang: 1.16
commands:
- 'go version'
- 'go get ./...'
build:
commands:
- go test ./...
- |
VERSION="0.${CODEBUILD_BUILD_NUMBER:=0}.$(echo "${CODEBUILD_RESOLVED_SOURCE_VERSION:=$(date +%Y%m%d%H%M%S)}" | cut -c1-7)"
IMAGE="sundaeswap/toolkit-for-cardano:${VERSION}"
LATEST="sundaeswap/toolkit-for-cardano:latest"
echo "logging in to docker hub"
docker login --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}"
echo docker build -t "${IMAGE}" .
docker build -t "${IMAGE}" .
docker push "${IMAGE}"
echo docker tag "${IMAGE}" "${LATEST}"
docker tag "${IMAGE}" "${LATEST}"
docker push "${LATEST}"
echo "{\"image\":\"${VERSION}\"}" > version.json
REPO="$(basename "${CODEBUILD_SRC_DIR:=${ROOT}}")"
S3_KEY="${REPO}/$(basename "${CODEBUILD_WEBHOOK_HEAD_REF:=unknown}")/${VERSION}"
AWS_ACCESS_KEY_ID=${DEV_ACCESS_KEY_ID} \
AWS_SECRET_ACCESS_KEY=${DEV_SECRET_ACCESS_KEY} \
AWS_REGION=${DEV_REGION} \
aws s3 cp version.json s3://${S3_BUCKET}/${S3_KEY}/version.json
- |
SYNC_IMAGE="sundaeswap/cardano-db-sync:${VERSION}"
SYNC_LATEST="sundaeswap/cardano-db-sync:latest"
echo docker build -t "${IMAGE}" cardano-db-sync
docker build -t "${SYNC_IMAGE}" cardano-db-sync
docker push "${SYNC_IMAGE}"
echo docker tag "${SYNC_IMAGE}" "${SYNC_LATEST}"
docker tag "${SYNC_IMAGE}" "${SYNC_LATEST}"
docker push "${SYNC_LATEST}"
- |
CONFIGURE_IMAGE="sundaeswap/cardano-db-sync-configure:${VERSION}"
CONFIGURE_LATEST="sundaeswap/cardano-db-sync-configure:latest"
echo docker build -t "${IMAGE}" cardano-db-sync-configure
docker build -t "${CONFIGURE_IMAGE}" cardano-db-sync-configure
docker push "${CONFIGURE_IMAGE}"
echo docker tag "${CONFIGURE_IMAGE}" "${CONFIGURE_LATEST}"
docker tag "${CONFIGURE_IMAGE}" "${CONFIGURE_LATEST}"
docker push "${CONFIGURE_LATEST}"
cache:
paths:
- '/root/.cache/go-build/**/*'