-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (67 loc) · 2.15 KB
/
build-and-deploy.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
name: Build and push project
on:
push:
branches:
- '*'
permissions:
id-token: write
contents: read
env:
AWS_ACCOUNT_ID: '056331603841'
AWS_REGION: 'ap-southeast-2'
BUCKET_NAME: 'techfolio'
jobs:
build-and-deploy-spa:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Checking out code
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/github_actions_role
aws-region: ${{ env.AWS_REGION }}
role-session-name: samplerolesession1
- name: Build and deploy React App
run: |
ls
cd _spa
npm install && npm run build:production
- name: Deploy app build to S3 bucket
run: |
cd _spa
aws s3 sync --exclude "content.json" ./build/ s3://${{ env.BUCKET_NAME }} --delete
build-and-deploy-lambda:
runs-on: ubuntu-latest
steps:
- name: Checking out code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/github_actions_role
aws-region: ${{ env.AWS_REGION }}
role-session-name: samplerolesession2
- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install boto3 contentful
- name: Build deployment package
run: |
cd lambda
mkdir package
ls
cp lambda_function.py package/
cp -r ../venv/lib/python3.10/site-packages/* package/
cd package
zip -r ../../lambda_function.zip .
- name: Deploy Lambda
run: |
ls
aws lambda update-function-code --function-name techfolio-contentful --zip-file fileb://lambda_function.zip