-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathconfig.yml
More file actions
74 lines (69 loc) · 1.96 KB
/
Copy pathconfig.yml
File metadata and controls
74 lines (69 loc) · 1.96 KB
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
version: 2.1
orbs:
python: circleci/python@0.3.2
aws-cli: circleci/aws-cli@1.2.1
jobs:
build-and-test:
executor:
name: python/default
tag: '3.7'
steps:
- checkout
- run:
name: Setup Virtual env
command: |
virtualenv -p python3.7 env
echo "source ./env/bin/activate" >> $BASH_ENV
- run:
name: Install Dependencies
command: pip install -r requirements.txt
- run:
name: Create ENV file
command: env > .env
- run:
name: Test
command: pytest
- run:
name: Create Zipfile archive of Dependencies
command: |
cd env/lib/python3.7/site-packages
zip -r9 ../../../../function.zip .
- run:
name: Add App to Zipfile
command: zip -g ./function.zip .env -r app
- persist_to_workspace:
root: .
paths:
- function.zip
deploy-dev:
executor: aws-cli/default
steps:
- attach_workspace:
at: ./
- aws-cli/setup:
aws-region: AWS_DEFAULT_REGION
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
- run:
name: Upload to S3
command: aws s3 cp function.zip s3://cicd-test-1/function.zip
- run:
name: Deploy new Lambda
command: aws lambda update-function-code --function-name cicd-test-1 --s3-bucket cicd-test-1 --s3-key function.zip
workflows:
build-test-and-deploy:
jobs:
- build-and-test:
context: serverless-fastapi-dev
filters:
branches:
only:
- cicd-test-1
- deploy-dev:
context: serverless-fastapi-dev
requires:
- build-and-test
filters:
branches:
only:
- cicd-test-1