Skip to content

Commit

Permalink
Merge branch 'staging' into email-template-update-mailersend
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarvarela authored Dec 12, 2024
2 parents 281cc72 + bdecb4c commit a402015
Show file tree
Hide file tree
Showing 283 changed files with 19,051 additions and 176,138 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,35 @@ jobs:
- name: Install Netlify CLI
run: npm install netlify-cli -g

- name: Set branch context URL
continue-on-error: true
run: |
# Extract branch name from ref (removes refs/heads/ prefix)
if [[ ! -z "${{ inputs.netlify-alias }}" ]]; then
netlify env:set NEXTAUTH_URL ${{ inputs.site-url || vars.SITE_URL }} --context "branch:${{ inputs.netlify-alias }}"
fi
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }}
GITHUB_HEAD_REF: ${{ github.head_ref }}

- name: Build using Netlify
run: netlify build --context ${{ inputs.netlify-context }} --offline
working-directory: site/gatsby-site
env:
NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ vars.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }}
E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ vars.GATSBY_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }}
GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }}
GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }}
GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }}
MONGODB_CONNECTION_STRING: ${{ secrets.MONGODB_CONNECTION_STRING }}
MONGODB_REPLICA_SET: ${{ secrets.MONGODB_REPLICA_SET }}
MONGODB_TRANSLATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_TRANSLATIONS_CONNECTION_STRING }}
TRANSLATE_SUBMISSION_DATE_START: ${{ vars.TRANSLATE_SUBMISSION_DATE_START }}
MONGODB_MIGRATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_MIGRATIONS_CONNECTION_STRING }}
GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }}
GATSBY_PRISMIC_REPO_NAME: ${{ vars.GATSBY_PRISMIC_REPO_NAME }}
Expand All @@ -116,7 +124,6 @@ jobs:
CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
REALM_GRAPHQL_API_KEY: ${{ secrets.REALM_GRAPHQL_API_KEY }}
GATSBY_COMMIT_SHA: ${{ inputs.sha }}
TRANSLATE_DRY_RUN: ${{ vars.TRANSLATE_DRY_RUN }}
REALM_API_APP_ID: ${{ vars.REALM_API_APP_ID }}
REALM_API_GROUP_ID: ${{ vars.REALM_API_GROUP_ID }}
REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }}
Expand All @@ -125,7 +132,8 @@ jobs:
ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }}
API_MONGODB_CONNECTION_STRING: ${{ secrets.API_MONGODB_CONNECTION_STRING }}
SITE_URL: ${{ inputs.site-url || vars.SITE_URL }}
PROCESS_NOTIFICATIONS_SECRET: ${{ secrets.PROCESS_NOTIFICATIONS_SECRET }}
NEXTAUTH_URL: ${{ inputs.site-url || vars.SITE_URL }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}

- name: Build size
run: |
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ jobs:
netlify-context: branch-deploy
runner-label: ${{ vars.PREVIEW_RUNNER_LABEL }}

call-test:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/test.yml
needs: call-test-build
secrets: inherit
with:
sha: ${{ github.event.pull_request.head.sha }}
environment: staging
runner-label: ${{ vars.PREVIEW_RUNNER_LABEL }}

call-test-playwright:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/test-playwright.yml
Expand Down
67 changes: 38 additions & 29 deletions .github/workflows/process-notifications.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
name: Process Notifications

on:
workflow_call:
inputs:
environment:
description: The Github environment to load secrets from
type: string
required: true
environment:
description: The Github environment to load secrets from
type: string
required: true
force-deploy:
description: Skip processing notifications if force deploy is true
type: boolean
required: false
default: false

jobs:
execute-mutation:
execute-process:
if: ${{ inputs.force-deploy != true }}
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Call GraphQL API
env:
SITE_URL: ${{ vars.SITE_URL }}
PROCESS_NOTIFICATIONS_SECRET: ${{ secrets.PROCESS_NOTIFICATIONS_SECRET }}
run: |
RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X POST "$SITE_URL/api/graphql" \
-H "Content-Type: application/json" \
-H "PROCESS_NOTIFICATIONS_SECRET: $PROCESS_NOTIFICATIONS_SECRET" \
-d '{"query":"mutation { processNotifications }"}')
- name: Checkout code
uses: actions/checkout@v4

HTTP_STATUS=$RESPONSE
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: site/gatsby-site/package-lock.json

if [ "$HTTP_STATUS" -ne 200 ]; then
echo "GraphQL mutation failed with HTTP status: $HTTP_STATUS"
cat response.json
exit 1
fi
- name: Install dependencies
working-directory: site/gatsby-site
run: npm ci

if jq -e 'has("errors") or has("errorType")' response.json > /dev/null; then
echo "GraphQL mutation failed with the following response:"
jq '.' response.json
exit 1
fi
echo "GraphQL mutation succeeded!"
jq '.' response.json
- name: Process Notifications
working-directory: site/gatsby-site
env:
REALM_API_APP_ID: ${{ vars.REALM_API_APP_ID }}
REALM_API_GROUP_ID: ${{ vars.REALM_API_GROUP_ID }}
REALM_API_PRIVATE_KEY: ${{ secrets.REALM_API_PRIVATE_KEY }}
REALM_API_PUBLIC_KEY: ${{ secrets.REALM_API_PUBLIC_KEY }}
REALM_GRAPHQL_API_KEY: ${{ secrets.REALM_GRAPHQL_API_KEY }}
REALM_APP_ID: ${{ vars.REALM_APP_ID }}
API_MONGODB_CONNECTION_STRING: ${{ secrets.API_MONGODB_CONNECTION_STRING }}
ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN: ${{ secrets.ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN }}
MAILERSEND_API_KEY: ${{ secrets.MAILERSEND_API_KEY }}
NOTIFICATIONS_SENDER_NAME: ${{ vars.NOTIFICATIONS_SENDER_NAME }}
NOTIFICATIONS_SENDER: ${{ vars.NOTIFICATIONS_SENDER }}
SITE_URL: ${{ vars.SITE_URL }}
run: npm run process-notifications:ci
24 changes: 11 additions & 13 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ jobs:
runner-label: ${{ vars.PRODUCTION_RUNNER_LABEL }}
cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }}

call-test:
uses: ./.github/workflows/test.yml
needs: [cache-modifier, call-test-build]
secrets: inherit
with:
sha: ${{ github.sha }}
environment: production
runner-label: ${{ vars.PRODUCTION_RUNNER_LABEL }}
cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }}

call-test-playwright:
uses: ./.github/workflows/test-playwright.yml
needs: call-test-build
Expand All @@ -84,7 +74,13 @@ jobs:
call-deploy:
if: (inputs.force-deploy == true || success()) && !cancelled()
uses: ./.github/workflows/deploy.yml
needs: [cache-modifier, call-test, call-test-api, call-test-playwright, call-test-playwright-full]
needs:
[
cache-modifier,
call-test-api,
call-test-playwright,
call-test-playwright-full,
]
secrets: inherit
permissions:
pull-requests: write
Expand All @@ -95,10 +91,12 @@ jobs:
netlify-alias:
runner-label: ${{ vars.PRODUCTION_RUNNER_LABEL }}
cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }}

call-process-notifications:
needs: call-deploy
uses: ./.github/workflows/process-notifications.yml
secrets: inherit
with:
environment: production
environment: production
# inputs from the workflow_dispatch event come as strings even if they are explicitly defined as boolean
force-deploy: ${{ inputs.force-deploy == 'true' }}
25 changes: 0 additions & 25 deletions .github/workflows/realm-empty-env.yml

This file was deleted.

16 changes: 4 additions & 12 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ jobs:
environment: staging
runner-label: ${{ vars.STAGING_RUNNER_LABEL }}

call-test:
uses: ./.github/workflows/test.yml
needs: [cache-modifier, call-test-build]
secrets: inherit
with:
sha: ${{ github.sha }}
environment: staging
runner-label: ${{ vars.STAGING_RUNNER_LABEL }}
cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }}

call-test-playwright-full:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/test-playwright-full.yml
Expand All @@ -83,7 +73,7 @@ jobs:
call-deploy:
if: (inputs.force-deploy == true || success()) && !cancelled()
uses: ./.github/workflows/deploy.yml
needs: [cache-modifier, call-test, call-test-playwright, call-test-api]
needs: [cache-modifier, call-test-playwright, call-test-api]
secrets: inherit
permissions:
pull-requests: write
Expand All @@ -94,10 +84,12 @@ jobs:
netlify-alias:
runner-label: ${{ vars.STAGING_RUNNER_LABEL }}
cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }}

call-process-notifications:
needs: call-deploy
uses: ./.github/workflows/process-notifications.yml
secrets: inherit
with:
environment: staging
# inputs from the workflow_dispatch event come as strings even if they are explicitly defined as boolean
force-deploy: ${{ inputs.force-deploy == 'true' }}
17 changes: 8 additions & 9 deletions .github/workflows/test-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,20 @@ jobs:
- name: Jest run
run: npm run test:api:ci
env:
REALM_APP_ID: ""
REALM_API_APP_ID: ""
REALM_API_GROUP_ID: ""
REALM_API_PUBLIC_KEY: ""
REALM_API_PRIVATE_KEY: ""
REALM_GRAPHQL_API_KEY: ""
REALM_APP_ID: dummy
REALM_API_APP_ID: dummy
REALM_API_GROUP_ID: dummy
REALM_API_PUBLIC_KEY: dummy
REALM_API_PRIVATE_KEY: dummy
REALM_GRAPHQL_API_KEY: dummy
API_MONGODB_CONNECTION_STRING: "" # dinamically set by globalSetup.ts
E2E_ADMIN_USERNAME: ""
E2E_ADMIN_PASSWORD: ""
ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN: sarasa
MAILERSEND_API_KEY: something
NOTIFICATIONS_SENDER_NAME: Test Preview
NOTIFICATIONS_SENDER: [email protected]
PROCESS_NOTIFICATIONS_SECRET: sarasa
SITE_URL: http://localhost:8000
NEXTAUTH_URL: http://localhost:8000
NEXTAUTH_SECRET: dummy

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,12 @@ jobs:
with:
path: |
site/gatsby-site/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ inputs.cache-modifier}}

- name: Install NPM dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
uses: cypress-io/github-action@v6
with:
working-directory: site/gatsby-site
runTests: false
install-command: npm ci
working-directory: site/gatsby-site
run: npm ci

- name: Use tests specific netlify.toml
run: mv tests-netlify.toml netlify.toml
Expand All @@ -80,21 +76,17 @@ jobs:
NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ vars.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }}
E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ vars.GATSBY_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }}
GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }}
GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }}
GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }}
MONGODB_CONNECTION_STRING: ${{ secrets.MONGODB_CONNECTION_STRING }}
MONGODB_REPLICA_SET: ${{ secrets.MONGODB_REPLICA_SET }}
MONGODB_TRANSLATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_TRANSLATIONS_CONNECTION_STRING }}
MONGODB_MIGRATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_MIGRATIONS_CONNECTION_STRING }}
TRANSLATE_SUBMISSION_DATE_START: ${{ vars.TRANSLATE_SUBMISSION_DATE_START }}
GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }}
GATSBY_PRISMIC_REPO_NAME: ${{ vars.GATSBY_PRISMIC_REPO_NAME }}
PRISMIC_ACCESS_TOKEN: ${{ secrets.PRISMIC_ACCESS_TOKEN }}
Expand All @@ -115,7 +107,8 @@ jobs:
REALM_API_PRIVATE_KEY: ${{ secrets.REALM_API_PRIVATE_KEY }}
ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }}
API_MONGODB_CONNECTION_STRING: ${{ secrets.API_MONGODB_CONNECTION_STRING }}

NEXTAUTH_URL: http://localhost:8000
NEXTAUTH_SECRET: 678x1irXYWeiOqTwCv1awvkAUbO9eHa5xzQEYhxhMms= # only used in local tests

- name: Cache build
uses: actions/cache/save@v4
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/test-playwright-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
with:
path: |
site/gatsby-site/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ inputs.cache-modifier }}

- name: Install NPM dependencies
Expand All @@ -57,7 +56,7 @@ jobs:
working-directory: site/gatsby-site

- name: start in memory mongodb
run: nohup node -r ts-node/register playwright/memory-mongo.ts &
run: nohup npm run start:memory-mongo:ci &
working-directory: site/gatsby-site
env:
MONGODB_CONNECTION_STRING: mongodb://127.0.0.1:4110/
Expand Down Expand Up @@ -85,11 +84,9 @@ jobs:
GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }}
GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }}
GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }}
GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }}
MONGODB_CONNECTION_STRING: mongodb://127.0.0.1:4110/
MONGODB_TRANSLATIONS_CONNECTION_STRING: mongodb://127.0.0.1:4110/
MONGODB_MIGRATIONS_CONNECTION_STRING: mongodb://127.0.0.1:4110/
TRANSLATE_SUBMISSION_DATE_START: ${{ vars.TRANSLATE_SUBMISSION_DATE_START }}
GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }}
GATSBY_PRISMIC_REPO_NAME: ${{ vars.GATSBY_PRISMIC_REPO_NAME }}
PRISMIC_ACCESS_TOKEN: ${{ secrets.PRISMIC_ACCESS_TOKEN }}
Expand Down Expand Up @@ -137,8 +134,9 @@ jobs:
MAILERSEND_API_KEY: something
NOTIFICATIONS_SENDER_NAME: Test Preview
NOTIFICATIONS_SENDER: [email protected]
PROCESS_NOTIFICATIONS_SECRET: sarasa
SITE_URL: http://localhost:8000
NEXTAUTH_URL: http://localhost:8000
NEXTAUTH_SECRET: 678x1irXYWeiOqTwCv1awvkAUbO9eHa5xzQEYhxhMms= # only used in local tests

- name: Upload Playwright traces
if: failure()
Expand Down
Loading

0 comments on commit a402015

Please sign in to comment.