-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (78 loc) · 3.54 KB
/
build_lambda.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
name: Lambda deployment
on:
push:
branches:
- main
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
- name: Install dependencies
run: npm install
- name: Create zip bundle
run: |
zip -r deploy.zip . -x "*yarn.lock*" -x "*.git*" -x "*.gitignore*" -x "*deploy.sh*" -x "*package-lock.json*"
- uses: actions/upload-artifact@v3
with:
name: deploy-${{ github.sha }}
path: deploy.zip
deploy:
needs: build
runs-on: ubuntu-latest
env:
GITHUB_SHA: ${{ github.sha }}
steps:
- name: "Set dev AWS credentials"
if: ${{ github.ref == 'refs/heads/dev' }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
aws-region: ${{ secrets.AWS_REGION }}
- name: "Set prd AWS credentials"
if: ${{ github.ref == 'refs/heads/main' }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PRD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PRD }}
aws-region: ${{ secrets.AWS_REGION }}
- uses: actions/download-artifact@v3
with:
name: deploy-${{ github.sha }}
- name: "Upload dev deployment file"
if: ${{ github.ref == 'refs/heads/dev' }}
env:
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME_DEV }}
run: |
aws s3 rm s3://$AWS_S3_BUCKET_NAME/extract/deploy.zip
aws s3 cp deploy.zip s3://$AWS_S3_BUCKET_NAME/extract/deploy.zip
- name: "Upload production deployment file"
if: ${{ github.ref == 'refs/heads/main' }}
env:
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME_PRD }}
run: |
aws s3 rm s3://$AWS_S3_BUCKET_NAME/extract/deploy.zip
aws s3 cp deploy.zip s3://$AWS_S3_BUCKET_NAME/extract/deploy.zip
- name: "Update dev lambdas"
if: ${{ github.ref == 'refs/heads/dev' }}
env:
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME_DEV }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
aws lambda update-function-code --function-name fxhash-dev-extract-small --s3-bucket $AWS_S3_BUCKET_NAME --s3-key "extract/deploy.zip" --region $AWS_REGION
aws lambda update-function-code --function-name fxhash-dev-extract-medium --s3-bucket $AWS_S3_BUCKET_NAME --s3-key "extract/deploy.zip" --region $AWS_REGION
aws lambda update-function-code --function-name fxhash-dev-extract-large --s3-bucket $AWS_S3_BUCKET_NAME --s3-key "extract/deploy.zip" --region $AWS_REGION
- name: "Update production lambdas"
if: ${{ github.ref == 'refs/heads/main' }}
env:
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME_PRD }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
aws lambda update-function-code --function-name fxhash-prd-extract-small --s3-bucket $AWS_S3_BUCKET_NAME --s3-key "extract/deploy.zip" --region $AWS_REGION
aws lambda update-function-code --function-name fxhash-prd-extract-medium --s3-bucket $AWS_S3_BUCKET_NAME --s3-key "extract/deploy.zip" --region $AWS_REGION
aws lambda update-function-code --function-name fxhash-prd-extract-large --s3-bucket $AWS_S3_BUCKET_NAME --s3-key "extract/deploy.zip" --region $AWS_REGION