This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
942 changed files
with
38,035 additions
and
14,400 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Build to Cloudflare Pages | ||
|
||
permissions: | ||
actions: write | ||
checks: write | ||
contents: write | ||
deployments: write | ||
pull-requests: write | ||
statuses: write | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
env: | ||
NODE_OPTIONS: '--max-old-space-size=8192' | ||
|
||
concurrency: | ||
group: cloudflare-pages-build-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build_to_cloudflare_pages: | ||
runs-on: Ubuntu-latest | ||
steps: | ||
- name: Checkout to repo | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v2 | ||
|
||
- name: Generate build status comment | ||
id: build_status_comment | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
const preview_url = "https://" + "${{ github.head_ref }}" + ".deriv-com.pages.dev" | ||
const comment = [ | ||
'## Cloudflare Pages Preview link', | ||
'| Name | Result |', | ||
'| :--- | :------ |', | ||
`| **Build status** | In progress ⏳ |`, | ||
`| **Preview URL** | [Visit Preview](${preview_url}) |`, | ||
'' | ||
].join('\n') | ||
core.setOutput("comment", comment); | ||
- name: Update build status comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
only_update: true | ||
header: Cloudflare Pages Preview Comment | ||
number: ${{github.event.issue.number}} | ||
message: ${{steps.build_status_comment.outputs.comment}} | ||
|
||
- name: Get build output from master cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
key: master-cache-public | ||
restore-keys: | | ||
master-cache-public-replica | ||
path: | | ||
.cache | ||
public | ||
- name: Get cached dependencies | ||
id: cache-npm | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: node_modules | ||
key: npm-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install dependencies | ||
if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | ||
run: npm ci | ||
|
||
- name: Build project | ||
id: build-project | ||
run: npm run build | ||
|
||
- name: Publish to Cloudflare Pages | ||
uses: cloudflare/[email protected] | ||
|
||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }} | ||
command: pages publish public --project-name=deriv-com --branch=${GITHUB_REF_NAME} | ||
echo "preview_url=$(pages info --project-name=deriv-com --branch=${GITHUB_REF_NAME} --format preview_url)" >> $GITHUB_OUTPUT | ||
|
||
- name: Retrieve Cloudflare Pages Preview URL | ||
id: cloudflare_pages_preview_url | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
const preview_url = "${{ steps.publish-to-pages.outputs.preview_url }}" | ||
const comment = [ | ||
'| Name | Result |', | ||
'| :--- | :------ |', | ||
`| **Build status** | Completed ✅ |`, | ||
`| **Preview URL** | [Visit Preview](${preview_url}) |`, | ||
'' | ||
].join('\n') | ||
core.setOutput("comment", comment); | ||
- name: Post Cloudflare Pages Preview comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: Cloudflare Pages Preview Comment | ||
number: ${{github.event.issue.number}} | ||
message: ${{steps.cloudflare_pages_preview_url.outputs.comment}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: Core Web Vitals Audit | ||
|
||
permissions: | ||
actions: write | ||
checks: write | ||
contents: write | ||
deployments: write | ||
pull-requests: write | ||
statuses: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
core_web_vitals_audit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run Core Web Vitals Audit | ||
run: npm run audit | ||
|
||
- name: Install Datadog CI | ||
run: npm install -g @datadog/datadog-ci | ||
|
||
- name: Sync results with Datadog | ||
run: | | ||
datadog-ci synthetics upload --config datadog-ci.json | ||
datadog-ci synthetics results --config datadog-ci.json > results.json | ||
env: | ||
DATADOG_API_KEY: ${{ secrets.GATSBY_DATADOG_CLIENT_TOKEN }} | ||
DATADOG_APP_KEY: ${{ secrets.GATSBY_DATADOG_APPLICATION_ID }} | ||
|
||
- name: Post audit comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
header: Core Web Vitals Audit | ||
message: | | ||
### Core Web Vitals Results | ||
- Largest Contentful Paint: ${{ steps.results.outputs.lcp }} | ||
- First Input Delay: ${{ steps.results.outputs.fid }} | ||
- Cumulative Layout Shift: ${{ steps.results.outputs.cls }} | ||
- name: Slack Notification 📣 | ||
uses: 8398a7/action-slack@v3 | ||
if: ${{ failure() }} | ||
with: | ||
status: custom | ||
fields: workflow,job,commit,repo | ||
custom_payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "plain_text", | ||
"emoji": true, | ||
"text": "It appears that this pull request has not met the required Core Web Vitals score." | ||
} | ||
}, | ||
{ | ||
"type": "divider" | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*User: <${{ github.event.pull_request.user.url }}|${{ github.event.pull_request.user.login }}>*\n*Link:* ${{ github.event.pull_request.html_url }}\n*Title:* ${{ github.event.pull_request.title }}\n*Status:* ${{ github.event.pull_request.state }}" | ||
}, | ||
"accessory": { | ||
"type": "image", | ||
"image_url": "${{ github.event.pull_request.user.avatar_url }}", | ||
"alt_text": "${{ github.event.pull_request.user.login }}" | ||
} | ||
}, | ||
{ | ||
"type": "divider" | ||
}, | ||
{ | ||
"type": "context", | ||
"elements": [ | ||
{ | ||
"type": "image", | ||
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/notificationsWarningIcon.png", | ||
"alt_text": "notifications warning icon" | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*<!subteam^S04RV6RFCTW> please check the PR*" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ env: | |
NODE_OPTIONS: "--max_old_space_size=7168" | ||
DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }} | ||
DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }} | ||
GATSBY_MAP_API_KEY: ${{ secrets.GATSBY_MAP_API_KEY }} | ||
|
||
jobs: | ||
release-production: | ||
|
@@ -47,32 +48,6 @@ jobs: | |
# For using same tag for staging and production we need to uncomment these two below lines: | ||
# with: | ||
# tagRegex: "production(.*)" | ||
- name: Building docker image 🐳 | ||
run: docker build -t ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME . | ||
|
||
- name: Verify nginx image | ||
run: | | ||
set -e | ||
docker run --rm ${{ secrets.DOCKHUB_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.DOCKHUB_ORGANISATION }}/deriv-com:latest | ||
docker push ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME | ||
- name: Deploy 🚀 | ||
run: | | ||
export NAMESPACE="deriv-com-production" | ||
export SERVICEACCOUNT_TOKEN=${{ secrets.SERVICEACCOUNT_TOKEN }} | ||
export DOCKERHUB_ORGANISATION=${{ secrets.DOCKERHUB_ORGANISATION }} | ||
export KUBE_SERVER=${{ secrets.KUBE_SERVER }} | ||
export CA=${{ secrets.CA }} | ||
git clone https://github.com/binary-com/devops-ci-scripts | ||
cd devops-ci-scripts/k8s-build_tools | ||
echo ${{ secrets.CA_CRT}} | base64 --decode > ca.crt | ||
./release.sh deriv-com $GIT_TAG_NAME | ||
|
||
- name: Deploy to Cloudflare ☁️ | ||
uses: cloudflare/[email protected] | ||
|
Oops, something went wrong.