Skip to content

fix answers test

fix answers test #4332

name: 'Deploy serverless to staging'
on:
pull_request:
types: [labeled, opened, synchronize]
paths:
# Trigger the job only when the serverless config or files have been changed
- .github/workflows/deploy_serverless_staging.yml
- serverless/**
- serverless.yml
- lib/**
jobs:
deploy:
if: |
(github.event.action == 'labeled' && github.event.label.name == ':rocket: serverless') ||
(github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, ':rocket: serverless'))
name: deploy
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
function_name: ['webhook-queueWorker', 'webhookChecker']
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/install
- name: Populate env file
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
run: |
sed -i 's/prd/stg/g' .ebstalk.apps.env/serverless.env
secrets_pattern='^(.+)=.*pull:secretsmanager:(.*):SecretString:([^:]+):?(.*)}}'
cat .ebstalk.apps.env/serverless.env | while read line; do
if [[ $line =~ $secrets_pattern ]]; then
env_var_name=${BASH_REMATCH[1]}
secret_name=${BASH_REMATCH[2]}
secret_json_key=${BASH_REMATCH[3]}
secret_version=${BASH_REMATCH[4]:-AWSCURRENT}
if [[ $secret_version =~ ^AWS ]]; then
secret_version_option=(--version-stage "$secret_version")
else
secret_version_option=(--version-id "$secret_version")
fi
secret_value=$(aws secretsmanager get-secret-value \
--region us-east-1 \
--secret-id "$secret_name" \
--query "SecretString" \
"${secret_version_option[@]}" \
| jq -r --arg keyname $secret_json_key '. | fromjson | .[$keyname]')
[ -z "$secret_value" ] && {
echo "$secret_name or $secret_json_key not found."
secret_value="SECRET_NOT_FOUND"
}
echo "$env_var_name=\"$secret_value\"" >> .env
fi
done
- name: Copy Prisma files
run: node copyPrismaFiles.js
ls -lA ./serverless/
- name: serverless deploy ${{ matrix.function_name }}
uses: ryanlawson/[email protected]
with:
args: deploy function -f ${{ matrix.function_name }} --force
env:
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1