-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
71 lines (64 loc) · 1.45 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
stages:
- test
- build
- package
- publish
variables:
AWS_DEFAULT_OUTPUT: text
AWS_DEFAULT_REGION: eu-west-1
AWS_REGION: eu-west-1
SAM_CLI_TELEMETRY: 0
cache:
key: ${CI_PIPELINE_ID}
test-template:
image: public.ecr.aws/sam/build-provided.al2
stage: test
before_script:
- pip install --quiet cfn-lint
script:
- sam validate
- cfn-lint --template ./template.yaml --format junit > ./template.cfn-lint.xml
artifacts:
reports:
junit: ./template.cfn-lint.xml
build:
image: lambci/lambda:build-python3.10
stage: build
script:
- sam build
artifacts:
paths:
- ./.aws-sam/
bucket:
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base
stage: build
script:
- export BUCKET="$(aws cloudformation list-exports --query "Exports[?Name=='DeploymentBucket'].Value")"
- echo "BUCKET=${BUCKET}" >>./bucket.env
artifacts:
reports:
dotenv: ./bucket.env
package:
stage: package
script:
- >-
sam package
--s3-bucket "${BUCKET}"
--s3-prefix "${CI_PROJECT_NAME}"
>./template.out.yml
artifacts:
paths:
- ./template.out.yml
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
deploy:
image: public.ecr.aws/sam/build-provided.al2
stage: deploy
variables:
# This component publishes to us-east-1.
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
script:
- sam publish --template-file ./template.out.yml
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH