Skip to content

temp: inspect error in getMessages #1018

temp: inspect error in getMessages

temp: inspect error in getMessages #1018

name: Deploy serverless-database-backup
on:
push:
branches:
- staging
- master
# Making sure that the current deployment is completed before the next one
concurrency: deploy-serverless-database-backup-${{ github.ref }}
env:
# Update this common config
DIRECTORY: serverless/database-backup
FUNCTION: database-backup
jobs:
set_environment:
outputs:
current_env: "${{ steps.set-environment.outputs.current_env }}"
runs-on: ubuntu-latest
steps:
- id: set-environment
run: |
echo "Running on branch ${{ github.ref }}"
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
echo "::set-output name=current_env::production"
else
echo "::set-output name=current_env::staging"
fi
lint-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: "16"
- name: Lint lock file
run: cd "$DIRECTORY" && npx lockfile-lint --type npm --path package-lock.json -o "https:" -o "file:" --allowed-hosts npm
- name: Test app code
run: cd "$DIRECTORY" && npm test
build_deploy_application:
needs: [set_environment, lint-test]
environment:
name: "${{ needs.set_environment.outputs.current_env }}"
env:
BRANCH: "${{ needs.set_environment.outputs.current_env }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: "16"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: "${{ secrets.AWS_ACCESS_KEY_ID }}"
aws-secret-access-key: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
aws-region: "${{ vars.AWS_DEFAULT_REGION }}"
- name: Set function name according to environment
id: function-name
run: echo "::set-output name=value::$FUNCTION-${{ needs.set_environment.outputs.current_env }}"
- name: Build
id: build-lambda
env:
ZIP_FILE: code.zip
PG_VERSION: "${{ secrets.PG_VERSION }}"
run: |
cd "$DIRECTORY"
npm ci
npm run build:docker
sudo zip -qr "$ZIP_FILE" build package.json node_modules/
echo "::set-output name=zip_path::$DIRECTORY/$ZIP_FILE"
- name: Check if lambda can be updated (1)
run: |
result=$(aws lambda get-function --function-name "${{ steps.function-name.outputs.value }}" --query 'Configuration.[State, LastUpdateStatus]')
echo "$result"
if [[ ! "$result" =~ "Successful" ]] || [[ ! "$result" =~ "Active" ]]; then
sleep 10;
fi
- name: Update function code
run: |
aws lambda update-function-code --function-name "${{ steps.function-name.outputs.value }}" \
--zip-file=fileb://${{ steps.build-lambda.outputs.zip_path }} --publish 2>&1
- name: Check if lambda can be updated (2)
run: |
result=$(aws lambda get-function --function-name "${{ steps.function-name.outputs.value }}" --query 'Configuration.[State, LastUpdateStatus]')
echo "$result"
if [[ ! "$result" =~ "Successful" ]] || [[ ! "$result" =~ "Active" ]]; then
sleep 10;
fi
- name: Update function config
env:
# Update the configuration
ROLE: "${{ secrets.BACKUP_ROLE }}"
RUNTIME: nodejs12.x
HANDLER: build/index.handler
TIMEOUT: 900
MEMORY_SIZE: 2048
TAG: "github-actions-${{ github.sha }}-${{ github.run_id }}-${{github.run_attempt}}"
# Update env vars
DB_URI: "${{ secrets.BACKUP_DB_URI }}"
DB_USE_IAM: "${{ secrets.DB_USE_IAM }}"
BACKUP_BUCKET_NAME: "${{ secrets.BACKUP_BUCKET_NAME }}"
GCP_SECRET_NAME: "${{ secrets.BACKUP_GCP_SECRET_NAME }}"
KEY_ENCRYPTION_PUBLIC_KEY: "${{ secrets.BACKUP_PUBLIC_KEY }}"
SENTRY_DSN: "${{ secrets.SERVERLESS_SENTRY_DSN }}"
CRONITOR_CODE: "${{ secrets.BACKUP_CRONITOR_CODE }}"
# Update environment variables in the command
run: |
aws lambda update-function-configuration --function-name="${{ steps.function-name.outputs.value }}" \
--role="$ROLE" --description="$TAG" --timeout="$TIMEOUT" --memory-size="$MEMORY_SIZE" --runtime="$RUNTIME" --handler="$HANDLER" \
--environment "Variables={DB_URI=$DB_URI,DB_USE_IAM=$DB_USE_IAM,BACKUP_BUCKET_NAME=$BACKUP_BUCKET_NAME,GCP_SECRET_NAME=$GCP_SECRET_NAME,KEY_ENCRYPTION_PUBLIC_KEY=$KEY_ENCRYPTION_PUBLIC_KEY,SENTRY_DSN=$SENTRY_DSN,CRONITOR_CODE=$CRONITOR_CODE}"