feat: trim fix #1639
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: Test and Deploy | |
concurrency: | |
group: mainline | |
cancel-in-progress: true | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
- './docs' | |
jobs: | |
deploy-permissions-changes: | |
name: Deploy Permissions Changes | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Deploy | |
shell: bash | |
run: yarn nx deploy:users | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: eu-west-2 | |
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} | |
# static-checks-2: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# with: | |
# fetch-depth: 0 | |
# - name: Setup node environment | |
# uses: ./.github/actions/setup-node-job | |
# - run: npx nx format:check | |
# - run: npx nx affected -t lint --parallel=3 | |
# - run: npx nx affected -t test --parallel=3 | |
# - run: npx nx affected -t types --parallel=3 | |
static-checks: | |
name: Run Static Checks | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
project: | |
- admin-app | |
- components | |
- config | |
- dynamo | |
- image-optimisation | |
- connect-gmail-to-cypress | |
- static-pages | |
- types | |
- read-gmail | |
- planner | |
- seed-cognito | |
- constants | |
- utils | |
- web-app | |
- meal-planning | |
- web-app-e2e | |
- authorise-cognito-jwt | |
target: | |
- test | |
- types | |
- lint | |
exclude: | |
- project: components | |
target: test | |
- project: web-app-e2e | |
target: test | |
- project: web-app-e2e | |
target: types | |
- project: admin-app | |
target: types | |
- project: admin-app | |
target: test | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Run ${{ matrix.target }} | |
run: yarn nx ${{ matrix.target }} ${{ matrix.project }} | |
build-next-app-for-cypress: | |
name: Build NextJS app (Cypress) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Build Application | |
uses: ./.github/actions/build | |
with: | |
env-name: cypress | |
datadog-app-id: ${{ secrets.DATADOG_APP_ID_CYPRESS }} | |
datadog-client-token: ${{ secrets.DATADOG_CLIENT_TOKEN_CYPRESS }} | |
build-next-app-for-test: | |
name: Build NextJS app (Test) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Build Application | |
uses: ./.github/actions/build | |
with: | |
env-name: test | |
datadog-app-id: ${{ secrets.DATADOG_APP_ID_TEST }} | |
datadog-client-token: ${{ secrets.DATADOG_CLIENT_TOKEN_TEST }} | |
build-next-app-for-prod: | |
name: Build NextJS app (Production) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Build Application | |
uses: ./.github/actions/build | |
with: | |
env-name: prod | |
datadog-app-id: ${{ secrets.DATADOG_APP_ID }} | |
datadog-client-token: ${{ secrets.DATADOG_CLIENT_TOKEN }} | |
# build-storybook: | |
# name: Build Storybook | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - name: Setup node environment | |
# uses: ./.github/actions/setup-node-job | |
# - name: Run | |
# run: yarn nx run components:build-storybook | |
# - name: Save Artifact | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: storybook | |
# path: dist/storybook/components | |
deploy-for-cypress: | |
name: Cypress Deploy | |
runs-on: ubuntu-latest | |
needs: [build-next-app-for-cypress] | |
environment: | |
name: Cypress | |
url: https://cypress.app.thenutritionistmcr.com | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Deploy | |
uses: ./.github/actions/deploy | |
with: | |
do-hotswap: true | |
seed: true | |
env-name: cypress | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
datadog-app-id: ${{ secrets.DATADOG_APP_ID }} | |
datadog-client-token: ${{ secrets.DATADOG_CLIENT_TOKEN }} | |
datadog-api-key: ${{ secrets.DATADOG_API_KEY }} | |
url: https://cypress.app.thenutritionistmcr.com | |
cypress-run: | |
name: E2E Tests | |
runs-on: ubuntu-latest | |
needs: [deploy-for-cypress] | |
container: | |
image: bwainwrighttnm/cypress:latest | |
options: --ipc=host | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Run E2E tests | |
uses: ./.github/actions/cypress | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
google-client-id: ${{ secrets.GOOGLE_CLIENT_ID }} | |
google-client-secret: ${{ secrets.GOOGLE_CLIENT_SECRET }} | |
google-refresh-token: ${{ secrets.GOOGLE_REFRESH_TOKEN }} | |
chargebee-token: ${{ secrets.CHARGEBEE_TOKEN }} | |
cognito-pool-id: eu-west-2_77z37j3Fb | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-cypress-report: | |
name: Deploy Cypress Report | |
if: always() | |
runs-on: ubuntu-latest | |
needs: [cypress-run] | |
environment: | |
name: github-pages | |
url: https://the-nutritionist-mcr.github.io/web/ | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Download Report | |
uses: actions/download-artifact@v3 | |
with: | |
name: cypress-report | |
path: docs | |
- name: Upload report | |
if: always() | |
uses: ./.github/actions/upload-pages | |
with: | |
path: ./docs | |
deploy-for-test: | |
name: Test Deploy | |
runs-on: ubuntu-latest | |
needs: [build-next-app-for-test, static-checks, cypress-run] | |
environment: | |
name: Test | |
url: https://test.app.thenutritionistmcr.com | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Deploy | |
uses: ./.github/actions/deploy | |
with: | |
env-name: test | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
datadog-app-id: ${{ secrets.DATADOG_APP_ID }} | |
datadog-client-token: ${{ secrets.DATADOG_CLIENT_TOKEN }} | |
datadog-api-key: ${{ secrets.DATADOG_API_KEY }} | |
url: https://test.app.thenutritionistmcr.com | |
deploy-for-prod: | |
name: Production Deploy | |
runs-on: ubuntu-latest | |
needs: [build-next-app-for-prod, static-checks, cypress-run] | |
environment: | |
name: Production | |
url: https://portal.thenutritionistmcr.com | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node environment | |
uses: ./.github/actions/setup-node-job | |
- name: Deploy | |
uses: ./.github/actions/deploy | |
with: | |
env-name: prod | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
app-env: production | |
datadog-app-id: ${{ secrets.DATADOG_APP_ID }} | |
datadog-client-token: ${{ secrets.DATADOG_CLIENT_TOKEN }} | |
datadog-api-key: ${{ secrets.DATADOG_API_KEY }} | |
url: https://portal.thenutritionistmcr.com |