Skip to content

Commit

Permalink
Merge branch 'padms/2346' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
padms committed Aug 6, 2024
2 parents 030e130 + a07f4a6 commit b930681
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/DEV-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ jobs:
dynatracePaaSToken: ${{ secrets.DYNATRACE_PAAS_TOKEN }}
dynatraceImage: ${{ secrets.DYNATRACE_PREPROD_IMAGE }}
archiveContentLink: ${{ vars.ARCHIVE_CONTENT_LINK }}
friendlyCaptchaSitekey: ${{ vars.FC_SITEKEY}}
friendlyCaptchaPuzzleEndpoint: ${{ vars.FC_PUZZLE_END_POINT}}
deployToBothClusters: true
environment: ${{ secrets.ENV }}
- uses: act10ns/slack@v2
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/PREPROD-webs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ jobs:
algoliaApiKey: ${{ secrets.ALGOLIA_SEARCH_API_KEY }}
environment: ${{ secrets.ENV }}
archiveContentLink: ${{ vars.ARCHIVE_CONTENT_LINK }}
friendlyCaptchaSitekey: ${{ vars.FC_SITEKEY}}
friendlyCaptchaPuzzleEndpoint: ${{ vars.FC_PUZZLE_END_POINT}}
- uses: act10ns/slack@v2
with:
status: ${{ job.status }}
Expand Down Expand Up @@ -147,8 +145,6 @@ jobs:
dynatraceImage: ${{ secrets.DYNATRACE_PREPROD_IMAGE }}
environment: ${{ secrets.ENV }}
archiveContentLink: ${{ vars.ARCHIVE_CONTENT_LINK }}
friendlyCaptchaSitekey: ${{ vars.FC_SITEKEY}}
friendlyCaptchaPuzzleEndpoint: ${{ vars.FC_PUZZLE_END_POINT}}
deployToBothClusters: true
- uses: act10ns/slack@v2
with:
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/deploy-websites/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ inputs:
deployToBothClusters:
description: 'Deploy app to both Radix clusters'
required: false
friendlyCaptchaSitekey:
description: 'Friendly captcha site key'
required: true
friendlyCaptchaPuzzleEndpoint:
description: 'Friendly captcha puzzle endpoint'
required: true
runs:
using: 'composite'
steps:
Expand Down Expand Up @@ -110,8 +104,6 @@ runs:
--build-arg ARG_DYNATRACE_IMAGE=${{ inputs.dynatraceImage || 'node:18-alpine' }} \
--build-arg ARG_ENV=${{ inputs.environment }} \
--build-arg ARG_ARCHIVE_CONTENT_LINK=${{ inputs.archiveContentLink }} \
--build-arg ARG_FRIENDLY_CAPTCHA_SITEKEY=${{ inputs.friendlyCaptchaSitekey}} \
--build-arg ARG_FRIENDLY_CAPTCHA_PUZZLE_ENDPOINT=${{ inputs.friendlyCaptchaPuzzleEndpoint}}
--file web/Dockerfile \
--tag ${{ inputs.imageName }}:${{ env.IMAGE_TAG }} \
--tag ${{ inputs.imageName }}:${{ env.IMAGE_TAG_SHA }} \
Expand Down
18 changes: 18 additions & 0 deletions satellitesConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ const websiteDomains = {
global: {
url: 'https://www.equinor.com',
meta: 'Equinor',
fc_sitekey: 'FCMLCFU23ASH8D84',
fc_puzzle_endpoint: 'https://eu-api.friendlycaptcha.eu/api/v1/puzzle',
},
poland: {
url: 'https://www.equinor.pl',
Expand All @@ -103,6 +105,8 @@ const websiteDomains = {
brazil: {
url: 'https://www.equinor.com.br',
meta: 'equinor.com.br',
fc_sitekey: 'FCMLCFU238ACUELS',
fc_puzzle_endpoint: 'https://api.friendlycaptcha.com/api/v1/puzzle',
},
germany: {
url: 'https://www.equinor.de',
Expand Down Expand Up @@ -143,10 +147,14 @@ const websiteDomains = {
'global-development': {
url: 'localhost:3000',
meta: 'Equinor',
fc_sitekey: 'FCMLCFU23ASH8D84',
fc_puzzle_endpoint: 'https://eu-api.friendlycaptcha.eu/api/v1/puzzle',
},
'global-test': {
url: 'https://web-global-test-equinor-web-sites-test.c2.radix.equinor.com',
meta: 'Equinor',
fc_sitekey: 'FCMLCFU23ASH8D84',
fc_puzzle_endpoint: 'https://eu-api.friendlycaptcha.eu/api/v1/puzzle',
},
}

Expand Down Expand Up @@ -185,3 +193,13 @@ export const getDomain = (dataset) => websiteDomains[dataset]?.url || 'Domain no
export const getMetaTitleSuffix = (dataset) => {
return websiteDomains[dataset]?.meta || 'Equinor'
}

/**
* @param {string} dataset
*/
export const getFriendlyCaptchaConstants = (dataset) => {
return {
sitekey: websiteDomains[dataset]?.sitekey,
puzzleEndpoint: websiteDomains[dataset]?.puzzleEndpoint,
}
}
8 changes: 0 additions & 8 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ ARG ARG_SANITY_PROJECT_ID
ARG ARG_ALGOLIA_APP_ID
ARG ARG_ALGOLIA_SEARCH_API_KEY
ARG ARG_ARCHIVE_CONTENT_LINK
ARG ARG_FRIENDLY_CAPTCHA_SITEKEY
ARG ARG_FRIENDLY_CAPTCHA_PUZZLE_ENDPOINT

ENV NEXT_PUBLIC_SANITY_DATASET ${ARG_SANITY_DATASET}
ENV NEXT_PUBLIC_SANITY_PROJECT_ID ${ARG_SANITY_PROJECT_ID}
ENV SANITY_API_TOKEN ${ARG_SANITY_API_TOKEN}
ENV NEXT_PUBLIC_ALGOLIA_APP_ID ${ARG_ALGOLIA_APP_ID}
ENV NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY ${ARG_ALGOLIA_SEARCH_API_KEY}
ENV NEXT_PUBLIC_ARCHIVE_CONTENT_LINK ${ARG_ARCHIVE_CONTENT_LINK}
ENV NEXT_PUBLIC_FRIENDLY_CAPTCHA_SITEKEY ${ARG_FRIENDLY_CAPTCHA_SITEKEY}
ENV NEXT_PUBLIC_FRIENDLY_CAPTCHA_PUZZLE_ENDPOINT ${ARG_FRIENDLY_CAPTCHA_PUZZLE_ENDPOINT}

# https://nextjs.org/telemetry
ENV NEXT_TELEMETRY_DISABLED 1
Expand All @@ -57,15 +53,11 @@ ARG ARG_ENV
ARG ARG_SANITY_DATASET
ARG ARG_ALGOLIA_APP_ID
ARG ARG_ALGOLIA_SEARCH_API_KEY
ARG ARG_FRIENDLY_CAPTCHA_SITEKEY
ARG ARG_FRIENDLY_CAPTCHA_PUZZLE_ENDPOINT

ENV ENV ${ARG_ENV}
ENV NEXT_PUBLIC_SANITY_DATASET ${ARG_SANITY_DATASET}
ENV NEXT_PUBLIC_ALGOLIA_APP_ID ${ARG_ALGOLIA_APP_ID}
ENV NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY ${ARG_ALGOLIA_SEARCH_API_KEY}
ENV NEXT_PUBLIC_FRIENDLY_CAPTCHA_SITEKEY ${ARG_FRIENDLY_CAPTCHA_SITEKEY}
ENV NEXT_PUBLIC_FRIENDLY_CAPTCHA_PUZZLE_ENDPOINT ${ARG_FRIENDLY_CAPTCHA_PUZZLE_ENDPOINT}

ENV PORT 3000
ENV USER nextjs
Expand Down
10 changes: 9 additions & 1 deletion web/languages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { defaultWebLanguage, getDomain, getLanguages, getMetaTitleSuffix } from '../satellitesConfig.js'
import {
defaultWebLanguage,
getDomain,
getFriendlyCaptchaConstants,
getLanguages,
getMetaTitleSuffix,
} from '../satellitesConfig.js'

export const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET

Expand All @@ -9,3 +15,5 @@ export const defaultLanguage = languages.find((lang) => lang.id === defaultWebLa
export const domain = getDomain(dataset)

export const metaTitleSuffix = getMetaTitleSuffix(dataset)

export const friendlycaptcha = getFriendlyCaptchaConstants(dataset)
5 changes: 0 additions & 5 deletions web/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,3 @@ export const algolia = {
applicationId: process.env.NEXT_PUBLIC_ALGOLIA_APP_ID || '',
searchApiKey: process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY || '',
}

export const friendlyCaptcha = {
siteKey: process.env.NEXT_PUBLIC_FRIENDLY_CAPTCHA_SITEKEY || '',
puzzleEndpoint: process.env.NEXT_PUBLIC_FRIENDLY_CAPTCHA_PUZZLE_ENDPOINT || '',
}
7 changes: 4 additions & 3 deletions web/pageComponents/topicPages/Form/FriendlyCaptcha.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useEffect, useRef } from 'react'
import { WidgetInstance } from 'friendly-challenge'
import { friendlyCaptcha } from '../../../lib/config'
import { friendlycaptcha } from '../../../languages'

const FriendlyCaptcha = ({ doneCallback, errorCallback }) => {
const puzzleEndpoint = friendlyCaptcha.puzzleEndpoint
const sitekey = friendlycaptcha.sitekey
const puzzleEndpoint = friendlycaptcha.puzzleEndpoint
const container = useRef()
const widget = useRef()
useEffect(() => {
Expand All @@ -18,7 +19,7 @@ const FriendlyCaptcha = ({ doneCallback, errorCallback }) => {
}
}, [container, doneCallback, errorCallback, puzzleEndpoint])

return <div ref={container} className="frc-captcha" data-sitekey={friendlyCaptcha.siteKey} />
return <div ref={container} className="frc-captcha" data-sitekey={sitekey} />
}

export default FriendlyCaptcha

0 comments on commit b930681

Please sign in to comment.