diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 000000000..707dd8ac2 --- /dev/null +++ b/.github/workflows/staging.yml @@ -0,0 +1,19 @@ +name: Staging +on: + push: + branches: + - develop + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: develop + - uses: amondnet/now-deployment@v2 + id: now-deployment + with: + zeit-token: ${{ secrets.ZEIT_TOKEN }} + now-org-id: ${{ secrets.NOW_STAGING_ORG_ID }} + now-project-id: ${{ secrets.NOW_STAGING_PROJECT_ID }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index db812d06e..b75a04ca9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ out dist lib *-*.log +.now \ No newline at end of file diff --git a/config.js b/config.js new file mode 100644 index 000000000..c947ef612 --- /dev/null +++ b/config.js @@ -0,0 +1,19 @@ +module.exports = { + url: { + production: { + LANDING: "https://craft.js.org/", + DOCUMENTATION: "https://craft.js.org/r/docs/overview/", + BASIC_EXAMPLE: "https://craft.js.org/examples/basic/" + }, + staging: { + LANDING: "https://craft-js.prevwong.now.sh/", + DOCUMENTATION: "https://craft-js.prevwong.now.sh/r/docs/overview/", + BASIC_EXAMPLE: "https://craft-js.prevwong.now.sh/examples/basic/" + }, + development: { + LANDING: "http://localhost:3001/", + DOCUMENTATION: "http://localhost:3000/r/docs/overview/", + BASIC_EXAMPLE: "http://localhost:3002/" + } + }[process.env.ENV || 'staging'] +} diff --git a/package.json b/package.json index cbeebd0b4..e6a8368be 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "clean": "lerna run clean --stream", "build": "lerna run build --stream --ignore docs --ignore example-*", "build:all" : "lerna run build --stream", - "deploy": "./scripts/deploy.sh", + "deploy": "cross-env ENV=production ./scripts/deploy.sh", + "deploy:staging": "cross-env ENV=staging ./scripts/deploy.sh", "release": "run-s lint clean build test release:npm", "release:npm": "lerna publish", "test:watch": "jest --watch", diff --git a/packages/docs/src/pages/index.js b/packages/docs/src/pages/index.js index dfba8b694..08c94218b 100755 --- a/packages/docs/src/pages/index.js +++ b/packages/docs/src/pages/index.js @@ -7,11 +7,11 @@ import React from "react"; import {Redirect} from '@docusaurus/router'; - +import config from "../../../../config"; function Home() { - if (typeof window !== 'undefined') { - window.location.href="https://prevwong.github.io/craft.js"; + if (typeof window !== 'undefined' && process.env.NODE_ENV != "development") { + window.location.href=config.url["LANDING"]; return
Redirecting...
} else { return