-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds CDN deployments to gh pages (#1125)
* feat: adds CDN deployments to gh pages * feat: add versioning to the deploys * feat: adds version cleanup to avoid bad pathing * chore: renames cdn to static
- Loading branch information
1 parent
a954015
commit 744ab6d
Showing
4 changed files
with
168 additions
and
0 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,43 @@ | ||
name: Deploy to CDN | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Tag to deploy' | ||
required: true | ||
default: '' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.tag }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install Yarn 3 | ||
run: yarn set version 3.5.1 | ||
|
||
- name: Install Dependencies | ||
run: yarn install --immutable | ||
|
||
- name: Run deploy script | ||
env: | ||
tag: ${{ github.event.inputs.tag }} | ||
run: bash ./scripts/deploy-cdn.sh | ||
|
||
- name: Deploy dapps | ||
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 | ||
with: | ||
personal_token: ${{ secrets.DEPLOY_TOKEN }} | ||
# force_orphan: true # removing for now as it is incompatible with keep_files | ||
keep_files: true # Important to keep the rest of the files deployed previously | ||
publish_dir: ./deployments |
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,43 @@ | ||
name: Deploy to CDN | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Tag to deploy' | ||
required: true | ||
default: '' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.tag }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install Yarn 3 | ||
run: yarn set version 3.5.1 | ||
|
||
- name: Install Dependencies | ||
run: yarn install --immutable | ||
|
||
- name: Run deploy script | ||
env: | ||
tag: ${{ github.event.inputs.tag }} | ||
run: bash ./scripts/deploy-static.sh | ||
|
||
- name: Deploy dapps | ||
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 | ||
with: | ||
personal_token: ${{ secrets.DEPLOY_TOKEN }} | ||
# force_orphan: true # removing for now as it is incompatible with keep_files | ||
keep_files: true # Important to keep the rest of the files deployed previously | ||
publish_dir: ./deployments |
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,41 @@ | ||
#!/bin/bash | ||
|
||
# Stop on first error | ||
set -e | ||
|
||
# Make sure to start from base workspace folder | ||
reldir="$( dirname -- "$0"; )"; | ||
cd "$reldir/.."; | ||
|
||
build_sdk() { | ||
echo "\n---------- Building SDK -------------\n" | ||
yarn build | ||
echo "\n---------- Done building SDK -------------\n" | ||
} | ||
|
||
copy_to_deployment_dir() { | ||
local deployment_dir=$1 | ||
echo "\n---------- Copying to deployment directory -------------\n" | ||
cp -r packages/sdk/dist/browser/iife/metamask-sdk.js "$deployment_dir" | ||
cp -r packages/sdk/dist/browser/iife/metamask-sdk.js.map "$deployment_dir" | ||
echo "\n---------- Done copying to deployment directory -------------\n" | ||
} | ||
|
||
# ------ Start | ||
deployment_folder="cdn" | ||
gh_tag=$tag | ||
gh_tag_version=$(echo "$gh_tag" | sed -E 's/@metamask\/sdk@([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | ||
|
||
# Sanitize tag version | ||
deployment_dir="deployments/$deployment_folder/$gh_tag_version" | ||
|
||
echo "Deployment folder: $deployment_folder" | ||
echo "Deployment directory: $deployment_dir" | ||
|
||
mkdir -p "$deployment_dir" | ||
|
||
# Build SDK from root | ||
build_sdk | ||
|
||
# Copy to deployment directory | ||
copy_to_deployment_dir "$deployment_dir" |
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,41 @@ | ||
#!/bin/bash | ||
|
||
# Stop on first error | ||
set -e | ||
|
||
# Make sure to start from base workspace folder | ||
reldir="$( dirname -- "$0"; )"; | ||
cd "$reldir/.."; | ||
|
||
build_sdk() { | ||
echo "\n---------- Building SDK -------------\n" | ||
yarn build | ||
echo "\n---------- Done building SDK -------------\n" | ||
} | ||
|
||
copy_to_deployment_dir() { | ||
local deployment_dir=$1 | ||
echo "\n---------- Copying to deployment directory -------------\n" | ||
cp -r packages/sdk/dist/browser/iife/metamask-sdk.js "$deployment_dir" | ||
cp -r packages/sdk/dist/browser/iife/metamask-sdk.js.map "$deployment_dir" | ||
echo "\n---------- Done copying to deployment directory -------------\n" | ||
} | ||
|
||
# ------ Start | ||
deployment_folder="static" | ||
gh_tag=$tag | ||
gh_tag_version=$(echo "$gh_tag" | sed -E 's/@metamask\/sdk@([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | ||
|
||
# Sanitize tag version | ||
deployment_dir="deployments/$deployment_folder/$gh_tag_version" | ||
|
||
echo "Deployment folder: $deployment_folder" | ||
echo "Deployment directory: $deployment_dir" | ||
|
||
mkdir -p "$deployment_dir" | ||
|
||
# Build SDK from root | ||
build_sdk | ||
|
||
# Copy to deployment directory | ||
copy_to_deployment_dir "$deployment_dir" |