forked from aws-samples/drug-discovery-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
99 lines (86 loc) · 3.33 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
variables:
AWS_DEFAULT_REGION: us-east-1
DEV_BUCKET_PREFIX: build/dev
MAIN_BUCKET_PREFIX: build/main
default:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/amazonlinux:latest
include:
- template: Security/Secret-Detection.gitlab-ci.yml
stages:
- lint
- deploy-dev
- test
- deploy-main
################################
# .pre
################################
cfn-nag:
image:
name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/stelligent/cfn_nag
entrypoint: [""]
stage: lint
script:
- cfn_nag_scan --input-path build/cloudformation/*.yaml
secret_detection:
stage: lint
variables:
CI_DEBUG_TRACE: "true"
################################
# deploy-dev
################################
push-to-s3-dev:
stage: deploy-dev
before_script:
- yum update -y && yum install -y awscli zip
script:
- zip -r build/code.zip . -x .\*/\* -x .gitlab-ci.yml
- aws s3 cp build/code.zip s3://$DEV_DEPLOYMENT_BUCKET_NAME/$DEV_BUCKET_PREFIX/code/code.zip
- aws cloudformation package --template-file build/cloudformation/root.yaml --output-template build/cloudformation/packaged.yaml --region $AWS_DEFAULT_REGION --s3-bucket $DEV_DEPLOYMENT_BUCKET_NAME --s3-prefix $DEV_BUCKET_PREFIX
- aws s3 cp build/cloudformation/packaged.yaml s3://$DEV_DEPLOYMENT_BUCKET_NAME/$DEV_BUCKET_PREFIX/packaged.yaml
artifacts:
paths:
- build/cloudformation/packaged.yaml
expire_in: 1 day
only:
- dev
################################
# test
################################
test_cfn:
image: python:3.11
stage: test
timeout: 1h
before_script:
- python --version # For debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install taskcat
- pip freeze
script:
- taskcat test run
only:
- dev
################################
# deploy-main
################################
push-to-s3-main:
stage: deploy-main
before_script:
- yum update -y && yum install -y awscli zip
script:
- zip -r build/code.zip . -x .\*/\* -x .gitlab-ci.yml
- aws s3 cp build/code.zip s3://$MAIN_DEPLOYMENT_BUCKET_NAME/$MAIN_BUCKET_PREFIX/code/code.zip
- aws cloudformation package --template-file build/cloudformation/root.yaml --output-template build/cloudformation/packaged.yaml --region $AWS_DEFAULT_REGION --s3-bucket $MAIN_DEPLOYMENT_BUCKET_NAME --s3-prefix $MAIN_BUCKET_PREFIX
- aws s3 cp build/cloudformation/packaged.yaml s3://$MAIN_DEPLOYMENT_BUCKET_NAME/$MAIN_BUCKET_PREFIX/packaged.yaml
only:
- main