Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:binary-com/deriv-com into mayuran…
Browse files Browse the repository at this point in the history
…/accumulator_video
  • Loading branch information
mayuran-deriv committed Apr 16, 2024
2 parents 9f82ae8 + d910de3 commit faf6465
Show file tree
Hide file tree
Showing 6 changed files with 4,820 additions and 4,654 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/production-eu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,84 @@ jobs:
name: production
path: sites/eu/public
retention-days: 5
- name: Slack Notification 📣
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,repo
if_mention: failure,cancelled
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Release for *Deriv.com* with version *$GIT_TAG_NAME*`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: always()

build_and_publish_to_docker_k8s:
runs-on: Runner_16cores
environment: production
needs: [release-production]
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: production
path: sites/eu/public
- name: Set version env variable
run: echo "GIT_TAG_NAME=$(cat public/version.txt)" >> $GITHUB_ENV
- name: Building docker image 🐳
run: docker build -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME .

- name: Verify nginx image
run: |
set -e
docker run --rm ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME nginx -t
echo "docker image validated successfully"
- name: Pushing Image to docker hub 🐳
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }}| docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest
docker push ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME
- name: Deploy 🚀
id: build_and_push_docker_image
env:
KUBE_SERVER: ${{ secrets.KUBE_SERVER }}
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
CA_CRT: ${{ secrets.CA_CRT }}
NAMESPACE: deriv-com-production-eu
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
run: |
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo "${{ env.CA_CRT }}" | base64 --decode > ca.crt
export CA="ca.crt"
./release.sh deriv-com ${{ github.ref_name }}
- name: Send Slack Notification on Docker Publish and Kubernetes Deployment Failure
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,repo
if_mention: failure,cancelled
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Release for *Deriv.com* with version *$GIT_TAG_NAME* has failed`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: failure()
81 changes: 81 additions & 0 deletions .github/workflows/production-row.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,84 @@ jobs:
name: production
path: sites/row/public
retention-days: 5
- name: Slack Notification 📣
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,repo
if_mention: failure,cancelled
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Release for *Deriv.com* with version *$GIT_TAG_NAME*`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: always()

build_and_publish_to_docker_k8s:
runs-on: Runner_16cores
environment: production
needs: [release-production]
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: production
path: sites/row/public
- name: Set version env variable
run: echo "GIT_TAG_NAME=$(cat public/version.txt)" >> $GITHUB_ENV
- name: Building docker image 🐳
run: docker build -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME .

- name: Verify nginx image
run: |
set -e
docker run --rm ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME nginx -t
echo "docker image validated successfully"
- name: Pushing Image to docker hub 🐳
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }}| docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:latest
docker push ${{ secrets.DOCKERHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME
- name: Deploy 🚀
id: build_and_push_docker_image
env:
KUBE_SERVER: ${{ secrets.KUBE_SERVER }}
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
CA_CRT: ${{ secrets.CA_CRT }}
NAMESPACE: deriv-com-production-row
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
run: |
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo "${{ env.CA_CRT }}" | base64 --decode > ca.crt
export CA="ca.crt"
./release.sh deriv-com ${{ github.ref_name }}
- name: Send Slack Notification on Docker Publish and Kubernetes Deployment Failure
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,repo
if_mention: failure,cancelled
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Release for *Deriv.com* with version *$GIT_TAG_NAME* has failed`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: failure()
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { StyledHeader } from '../utils/_affiliate-header'
import AccountCard, { AccountCardProps, MainWrapper } from '../utils/_account-card'
import { Localize } from 'components/localization'
import { useIsRtl } from 'components/hooks/use-isrtl'
import { cpa_plan_countries, eu_countries } from 'common/country-base'
import Revenue from 'images/svg/signup-affiliates/revenue.svg'
import Turnover from 'images/svg/signup-affiliates/turnover.svg'
import CPA from 'images/svg/signup-affiliates/cpa.svg'
import useBuildVariant from 'features/hooks/use-build-variant'

const getPlans = (is_cpa_plan_aff: boolean): AccountCardProps[] => {
const getPlans = (country: string): AccountCardProps[] => {
const plans: AccountCardProps[] = [
{
value: 2,
Expand All @@ -26,7 +26,7 @@ const getPlans = (is_cpa_plan_aff: boolean): AccountCardProps[] => {
"_t_Earn based on each contract's payout probability or client's trade. <0>Learn more</>_t_",
},
]
if (is_cpa_plan_aff) {
if (cpa_plan_countries.includes(country) || eu_countries.includes(country)) {
plans.push({
value: 6,
icon: CPA,
Expand All @@ -46,11 +46,11 @@ const AccountPlan = ({
affiliate_account,
updateData,
onValidate,
is_cpa_plan_aff,
}: AccountPlanProps) => {
}: WizardStepProps<'account_plan'>) => {
const [account_plan, setAccountPlan] = useState(affiliate_account.account_plan)
const is_rtl = useIsRtl()
const plans = getPlans(is_cpa_plan_aff)
const plans = getPlans(affiliate_account.account_address.country.symbol)

useEffect(() => {
updateData(account_plan)
onValidate(!!account_plan)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react'
import { Analytics } from '@deriv-com/analytics'
import styled from 'styled-components'
import { Submit, trackEvent } from './utils/_utils'
import { AffiliateAccountTypes, SignUpStatusTypes } from './_types'
Expand Down Expand Up @@ -111,6 +112,7 @@ const AffiliateSignup = ({ pageContext }: TGatsbyHead) => {
JSON.stringify(affiliate_api_error?.echo_req) ||
'success, but without echo_req',
success_source: partner_signup_error_message ? 'failed_popup' : 'last_step',
affiliate_id: affiliate_api_data?.affiliate_user_id,
})
setSignupStatus('success')
} else if (partner_signup_error_message == 'Username not available') {
Expand Down Expand Up @@ -147,7 +149,7 @@ const AffiliateSignup = ({ pageContext }: TGatsbyHead) => {

return (
<Layout type="affiliates" padding_top="7" show_footer={false} region={region}>
<ParentWrapper pop_up_opened={!!signup_status}>
<ParentWrapper isPopupOpen={!!signup_status}>
<AtomicContainer.Fluid dir="row">
<StyledContainer>
{show_wizard ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
import { Analytics, TEvents } from '@deriv-com/analytics'
import { SubmitTypes } from '../_types'

const customSlugify = (text: string): string => {
const charMap: { [key: string]: string } = {
ə: 'e',
'(': ' ',
')': ' ',
// Add other special characters and their mappings here if needed
}
return text
.toString()
.split('')
.map((char) => charMap[char] || char)
.join('')
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.trim()
.replace(/'/g, '')
.replace(/--+/g, '-')
}

export const Submit = ({
is_online,
affiliate_account,
Expand All @@ -22,7 +41,7 @@ export const Submit = ({
country: affiliate_account.account_address.country.symbol,
address_city: affiliate_account.account_address.city.trim(),
address_postcode: affiliate_account.account_address.postal_code.trim(),
address_state: affiliate_account.account_address.state.symbol,
address_state: customSlugify(affiliate_account.account_address.state.name),
address_street: affiliate_account.account_address.street.trim(),
first_name: affiliate_account.account_details.first_name.trim(),
last_name: affiliate_account.account_details.last_name.trim(),
Expand Down Expand Up @@ -56,23 +75,6 @@ export const Submit = ({
})
}

export const trackEvent = ({
action,
email,
partner_signup_error_message,
user_choice,
success_source,
step_num,
step_codename,
}: TEvents['ce_partner_account_signup_form']) => {
Analytics?.trackEvent('ce_partner_account_signup_form', {
action,
form_name: 'ce_partner_account_signup_form',
...(email && { email }),
...(user_choice && { user_choice }),
...(success_source && { success_source }),
...(step_num && { step_num }),
...(step_codename && { step_codename }),
...(partner_signup_error_message && { partner_signup_error_message }),
})
export const trackEvent = (eventData: TEvents['ce_partner_account_signup_form']) => {
Analytics?.trackEvent('ce_partner_account_signup_form', eventData)
}
Loading

0 comments on commit faf6465

Please sign in to comment.