feat(aws): actions to deploy tools to AWS (#638) #1
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: Deploy NEWM Mobile Tools to AWS Hosting on merge | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- .github/workflows/aws-hosting-merge-deploy-newm-tools.yml | |
- apps/tools/** | |
- packages/** | |
workflow_dispatch: | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # required to interact with GitHub's OIDC Token endpoint. | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- run: npm install | |
- run: npx nx build tools | |
env: | |
NEXT_PUBLIC_APPLE_CLIENT_ID: ${{ secrets.APPLE_CLIENT_ID }} | |
NEXT_PUBLIC_GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} | |
NEXT_PUBLIC_GA_STUDIO_ID: ${{ secrets.GA_STUDIO_ID }} | |
NEXT_PUBLIC_RECAPTCHA_SITE_KEY_STAGING: ${{ secrets.RECAPTCHA_SITE_KEY_STAGING }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
NEXT_PUBLIC_ENV: staging | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.AWS_GITHUB_DEPLOY_ROLE_ARN_GARAGE }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Lambda-ify | |
run: echo "COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter" >> apps/tools/Dockerfile | |
- name: Install AWS CDK | |
run: npm install -g aws-cdk | |
- name: Set outputs | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Deploy to Lambda Function | |
run: | | |
npm install --prefix .github/workflows/cdk | |
APPNAME=tools APPID=Tools QUALIFIER=Garage NEXT_PUBLIC_RECAPTCHA_SITE_KEY_STAGING=${{ secrets.RECAPTCHA_SITE_KEY_STAGING }} npm run --prefix .github/workflows/cdk cdk:deploy deploy -- --require-approval never |