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

Commit

Permalink
chore: solve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jia-deriv committed Oct 5, 2023
2 parents 9efa7dd + d95c2cf commit f6a8e62
Show file tree
Hide file tree
Showing 257 changed files with 9,582 additions and 2,291 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
GATSBY_RUDDERSTACK_STAGING_KEY: ${{ secrets.GATSBY_RUDDERSTACK_STAGING_KEY }}
GATSBY_RUDDERSTACK_PRODUCTION_KEY: ${{ secrets.GATSBY_RUDDERSTACK_PRODUCTION_KEY }}
GATSBY_RUDDERSTACK_URL: ${{ secrets.GATSBY_RUDDERSTACK_URL }}

jobs:
release-beta:
timeout-minutes: 30
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages publish public --project-name=deriv-com-pages --branch=beta
command: pages deploy public --project-name=deriv-com-pages --branch=beta

- name: Cloudflare preview link ✨
run: echo "New beta website - https://beta.deriv.com"
Expand Down
91 changes: 85 additions & 6 deletions .github/workflows/generate-preview-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,36 @@ jobs:
run_id: ${{ github.event.workflow_run.id }}
name: 'pr-${{ github.event.workflow_run.id }}'

- name: Retrieve pull request and verify user organization
- name: Retrieve pull request
id: pr_information
run: |
echo "issue_number=$(cat ./NR)" > $GITHUB_OUTPUT
- name: 'Generate action link comment'
id: generate_action_url
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}"
const comment = [
'| Name | Result |',
'| :--- | :------ |',
`| **Build status** | Building 🔨 |`,
`| **Action URL** | [Visit Action](${action_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: ${{steps.pr_information.outputs.issue_number}}
message: ${{steps.generate_action_url.outputs.comment}}
recreate: true

- name: Verify user organization
id: verify_user_organization
run: |
echo "Verifying user's organization..."
user=$(cat ./USERNAME)
Expand All @@ -54,7 +82,6 @@ jobs:
else
echo "User is a member of binary-com organization."
echo "Proceeding to build and deploy for the pull request: https://github.com/binary-com/deriv-com/pull/$(cat ./NR)"
echo "issue_number=$(cat ./NR)" > $GITHUB_OUTPUT
fi
- name: Checkout to repo
uses: actions/checkout@v3
Expand Down Expand Up @@ -99,37 +126,89 @@ jobs:
echo "Deploying build to Cloudflare Pages"
directory='public'
projectName='deriv-com-preview-links'
branch=${{github.event.workflow_run.head_branch}}
head_branch=${{github.event.workflow_run.head_branch}}
branch=$(echo $head_branch | head -c 20)
preview_url=$(wrangler pages deploy $directory --project-name=$projectName --branch=$branch > log.txt 2>&1; echo $?)
echo "------"
cat log.txt
branchName=$(echo $branch | sed 's/[\/_\.]/-/g')
branchName=$(echo $branch | sed 's/[\/_\.]/-/g; s/[^a-zA-Z]$//')
if grep -q "Deployment complete" log.txt; then
echo "preview_url=https://$branchName.deriv-com-preview-links.pages.dev" > "$GITHUB_OUTPUT"
else
echo "Deployment to Cloudflare Pages failed."
exit 1
fi
- name: 'Generate preview link comment'
if: success()
id: generate_preview_url
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
const preview_url = `https://${{github.event.workflow_run.head_branch}}.deriv-com-preview-links.pages.dev`
const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}"
const preview_url = "${{steps.publish-to-pages.outputs.preview_url}}"
const comment = [
`**Preview Link**: ${preview_url}`,
'| Name | Result |',
'| :--- | :------ |',
`| **Build status** | Completed ✅ |`,
`| **Preview URL** | [Visit Preview](${preview_url}) |`,
`| **Action URL** | [Visit Action](${action_url}) |`,
''
].join('\n')
core.setOutput("comment", comment);
- name: 'Generate failure comment'
if: failure()
id: generate_failure_comment
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
const action_url = "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}"
const comment = [
'| Name | Result |',
'| :--- | :------ |',
`| **Build status** | Failed ❌ |`,
`| **Action URL** | [Visit Action](${action_url}) |`,
''
].join('\n')
core.setOutput("comment", comment);
- name: Post Cloudflare Pages Preview comment
if: success() || failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Cloudflare Pages Preview Comment
number: ${{steps.pr_information.outputs.issue_number}}
message: ${{steps.generate_preview_url.outputs.comment}}
message: ${{steps.generate_preview_url.outputs.comment || steps.generate_failure_comment.outputs.comment }}
recreate: true

- name: e2e Smoke Tests
uses: actions/checkout@v4
with:
repository: deriv-com/e2e-deriv-com # Replace with your repository name

- name: Cypress run
# Uses the official Cypress GitHub action https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
# Starts web server for E2E tests - replace with your own server invocation
# https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server
# start: npm start
# wait-on: 'http://localhost:3000' # Waits for above
# Records to Cypress Cloud
# https://docs.cypress.io/guides/cloud/projects#Set-up-a-project-to-record
record: true
parallel: true # Runs test in parallel using settings above
spec: cypress/e2e/smoke/*.js
group: 'Smoke Tests'

env:
# For recording and parallelization to work you must set your CYPRESS_RECORD_KEY
# in GitHub repo → Settings → Secrets → Actions
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Creating a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
# Set Base Url from client_payload.
CYPRESS_BASE_URL: ${{steps.publish-to-pages.outputs.preview_url}}
# Send PR and Repo details to Cypress Cloud test run
COMMIT_INFO_MESSAGE: PR "${{ github.event.pull_request.title }}" in Repo "${{ github.repository }}"
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages publish public --project-name=deriv-com-pages --branch=main
command: pages deploy public --project-name=deriv-com-pages --branch=main

- name: Cloudflare production link ✨
run: echo "New website - http://cf-pages-deriv-com.deriv.com"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages publish public --project-name=deriv-com-pages --branch=staging
command: pages deploy public --project-name=deriv-com-pages --branch=staging

- name: Cloudflare preview link ✨
run: echo "New staging website - http://staging.cf-pages-deriv-com.deriv.com"
Expand Down
Loading

0 comments on commit f6a8e62

Please sign in to comment.