-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
80 lines (70 loc) · 1.67 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
image: python:3.8-slim
stages:
- build
- build_dev
- deploy
- deploy_dev
- clean_dev
.installs: &installs
before_script:
- apt-get update
- apt-get install -y python3-pip
- pip3 install awscli --upgrade
- pip3 install aws-sam-cli --upgrade
.dev_only: &dev_only
except:
- main
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
BUCKET: lambda-deploy-gitlab
cache:
key:
files:
- .gitlab-ci.yml
- .template.yaml
prefix: ${CI_JOB_NAME}
paths:
- .cache/pip
build:
stage: build
<<: *installs
script:
- sam build
artifacts:
paths:
- .aws-sam
only:
- main
build_dev:
stage: build_dev
<<: *installs
script:
- sam build
artifacts:
paths:
- .aws-sam
<<: *dev_only
deploy:
stage: deploy
<<: *installs
script:
- sam package --output-template-file packaged.yaml --s3-bucket $BUCKET --region us-east-1
- sam deploy --template-file packaged.yaml --stack-name $CI_PROJECT_NAME --s3-bucket $BUCKET --capabilities CAPABILITY_IAM --region us-east-1 --no-fail-on-empty-changeset
allow_failure: true
only:
- main
deploy_dev:
stage: deploy_dev
<<: *installs
script:
- sam package --output-template-file packaged.yaml --s3-bucket $BUCKET-dev --region us-east-1
- sam deploy --template-file packaged.yaml --stack-name $CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG --s3-bucket $BUCKET-dev --capabilities CAPABILITY_IAM --region us-east-1 --no-fail-on-empty-changeset
allow_failure: true
<<: *dev_only
clean_dev:
stage: clean_dev
<<: *installs
script:
- sam delete --stack-name lambda-deploy-gitlab-dev --no-prompts --region us-east-1
when: manual
<<: *dev_only