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
219 changed files
with
16,203 additions
and
44,691 deletions.
There are no files selected for viewing
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,102 @@ | ||
name: Sync build cache | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
|
||
on: | ||
schedule: | ||
- cron: '0 22 * * *' | ||
workflow_dispatch: | ||
|
||
env: | ||
NODE_OPTIONS: '--max-old-space-size=8192' | ||
|
||
concurrency: | ||
group: sync-build-cache | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
validate-master-cache: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout to repo | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: master | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v2 | ||
|
||
- 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: Save cached dependencies | ||
if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | ||
uses: actions/cache/save@v3 | ||
with: | ||
key: ${{ steps.cache-npm.outputs.cache-primary-key }} | ||
path: node_modules | ||
|
||
- name: Get master cache | ||
id: restore-master-cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
key: master-cache-public | ||
path: | | ||
.cache | ||
public | ||
- name: Clear master cache | ||
if: ${{ steps.restore-master-cache.outputs.cache-hit == 'true' }} | ||
run: | | ||
owner="binary-com" | ||
repo="deriv-com" | ||
cache_key="${{ steps.restore-master-cache.outputs.cache-matched-key }}" | ||
curl \ | ||
-X DELETE \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: token ${{ github.token }}" \ | ||
https://api.github.com/repos/$owner/$repo/actions/caches?key=$cache_key | ||
- name: Rebuild master cache | ||
id: build-cache | ||
run: npm run build | ||
|
||
- name: Save master cache | ||
if: ${{ steps.build-cache.outcome == 'success' }} | ||
uses: actions/cache/save@v3 | ||
with: | ||
key: master-cache-public | ||
path: | | ||
.cache | ||
public | ||
- name: Clear backup cache | ||
if: ${{ steps.build-cache.outcome == 'success' }} | ||
run: | | ||
owner="binary-com" | ||
repo="deriv-com" | ||
cache_key="master-cache-public-replica" | ||
curl \ | ||
-X DELETE \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: token ${{ github.token }}" \ | ||
https://api.github.com/repos/$owner/$repo/actions/caches?key=$cache_key | ||
- name: Sync backup cache with master cache | ||
if: ${{ steps.build-cache.outcome == 'success' }} | ||
uses: actions/cache/save@v3 | ||
with: | ||
key: master-cache-public-replica | ||
path: | | ||
.cache | ||
public |
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
Oops, something went wrong.