-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
64 lines (60 loc) · 2.29 KB
/
.gitlab-ci.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
image: alpine:3.14
stages:
- build
- release
build docker:
image: tmaier/docker-compose:latest
stage: build
when: manual
variables:
IMAGE_TAG: qp3:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
script:
- IMAGE_SAFE_TAG=$(echo $IMAGE_TAG | sed s#/#-#g)
- pip install awscli
- aws configure set aws_access_key_id $AMI_AWS_ACCESS_KEY
- aws configure set aws_secret_access_key $AMI_AWS_SECRET_KEY
- aws configure set region eu-central-1
- aws ecr get-login-password | docker login --username AWS --password-stdin ${AMI_OWNER}.dkr.ecr.eu-central-1.amazonaws.com
- cd ./infrastructure
- docker build --no-cache -f=Dockerfile --tag=$IMAGE_SAFE_TAG
--build-arg S3_AWS_ACCESS_KEY=${S3_AWS_ACCESS_KEY}
--build-arg S3_AWS_SECRET_KEY=${S3_AWS_SECRET_KEY}
--build-arg SH_INSTANCE_ID=${SH_INSTANCE_ID}
--build-arg SH_CLIENT_ID=${SH_CLIENT_ID}
--build-arg SH_CLIENT_SECRET=${SH_CLIENT_SECRET}
--build-arg SENTINELHUB_BRANCH=${SENTINELHUB_BRANCH}
--build-arg EOLEARN_BRANCH=${EOLEARN_BRANCH}
--build-arg LCMS_BRANCH=${LCMS_BRANCH}
--build-arg HIECTOR_BRANCH=${CI_COMMIT_REF_NAME}
.
- docker tag ${IMAGE_SAFE_TAG} ${AMI_OWNER}.dkr.ecr.eu-central-1.amazonaws.com/${IMAGE_SAFE_TAG}
- docker push ${AMI_OWNER}.dkr.ecr.eu-central-1.amazonaws.com/${IMAGE_SAFE_TAG}
- echo ${IMAGE_SAFE_TAG}
release to github:
stage: release
when: always
only:
refs:
- tags
before_script:
- apk add --no-cache git openssh-client
script:
- mkdir -m 700 ~/.ssh
- echo "${GITHUB_SSH_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
- git config user.email "[email protected]"
- git config user.name "Gitlab CI"
- git remote rm github || true
- git remote add github [email protected]:sentinel-hub/hiector.git
- git branch -D github-upload || true
- git checkout -b github-upload
- git fetch origin release-changes
- git merge origin/release-changes
- git fetch github main
- git reset --soft github/main
- git commit -m "version $CI_COMMIT_TAG"
- git push github github-upload:main
- git push github HEAD:refs/tags/$CI_COMMIT_TAG