Skip to content

Fix : Blog API image issue (#599) #122

Fix : Blog API image issue (#599)

Fix : Blog API image issue (#599) #122

name: DeployBackendProd
on:
push:
branches:
- "master"
jobs:
deploy-backend-prod:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-go@v2
with:
go-version: "^1.22.3"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-backend-access
aws-region: ap-south-1
- name: Build backend and copy zip to S3
env:
RECAPTCHA_CONFIG_JSON_BASE64: ${{ secrets.RECAPTCHA_CONFIG_JSON_BASE64 }}
run: |
escaped_value=$(printf '%s' "$RECAPTCHA_CONFIG_JSON_BASE64" | tr -d '\n')
awk -v pattern="RECAPTCHA_CONFIG_JSON_BASE64" -v replacement="$escaped_value" '{gsub(pattern, replacement)} 1' utils/helper.go > recatpcha_config_key && mv recatpcha_config_key utils/helper.go
apt-get update && apt-get install -y zip
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o bootstrap main.go
zip canopas_serverless_prod_${{ github.sha }}.zip bootstrap
aws s3 cp canopas_serverless_prod_${{ github.sha }}.zip s3://canopas-lambda-handlers
- name: Deploy cloudformation stack
id: canopas-website-prod-lambda-stack
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: canopas-website-prod-lambda-stack
template: infrastructure/backend.yml
capabilities: CAPABILITY_IAM,CAPABILITY_NAMED_IAM
timeout-in-minutes: "10"
no-fail-on-empty-changeset: "1"
parameter-overrides: >-
EnvName=prod,
Sender=${{ secrets.SENDER }},
ContactSender=${{ secrets.CONTACT_SENDER }},
JobsReceiver=${{ secrets.JOBS_RECEIVER }},
ContactReceiver=${{ secrets.CONTACT_RECEIVER }},
AccessKeyId=${{ secrets.ACCESS_KEY_ID }},
SecretAccessKey=${{ secrets.SECRET_ACCESS_KEY }},
Region=${{ secrets.AWS_REGION }},
DbUsername=${{ secrets.DB_USERNAME }},
DbPassword=${{ secrets.DB_PASSWORD }},
DbHost=${{ secrets.DB_HOST }},
DbPort=${{ secrets.DB_PORT }},
DbName=${{ secrets.DB_NAME }},
BlogDbName=${{ secrets.BLOG_DB_NAME }},
RecaptchaSiteKey=${{ secrets.RECAPTCHA_SITE_KEY }},
RecaptchaProjectId=${{ secrets.RECAPTCHA_PROJECT_ID }},
JobsSpreadsheetId=${{ secrets.JOBS_SPREADSHEET_ID }},
GithubAccessToken=${{ secrets.PERSONAL_ACCESS_TOKEN_GITHUB }},
ResourcesURL=${{secrets.RESOURCES_URL}},
LambdaBucket=canopas-lambda-handlers,
LambdaUrl=canopas_serverless_prod_${{ github.sha }}.zip,
LambdaTimeout=10,
LambdaRoleName=canopas-prod-lambda-role,
LambdaName=canopas-prod-lambda-function,
ApiGatewayName=canopas-prod-lambda-api,
CustomDomainName=${{ secrets.PROD_SERVERLESS_DOMAIN }}