Merge pull request #12 from fxhash/revert-11-dev #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |