Skip to content

Commit

Permalink
setup staging environment
Browse files Browse the repository at this point in the history
move tokens to secrets

update staging github action

update staging action

fix

remove
  • Loading branch information
prevwong committed Feb 27, 2020
1 parent 12c7dd5 commit 912e743
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 7 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ out
dist
lib
*-*.log
.now
19 changes: 19 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -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']
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/docs/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <p style={{padding: "10px", textAlign:"center"}}>Redirecting...</p>
} else {
return <Redirect to="docs/overview" />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ export const Header = () => {
<h2 className="mr-5 text-xl">craft.js</h2>
</div>
<div className="flex items-end justify-end">
<Link href="https://craft.js.org/examples/basic">Another Example</Link>
<Link href={process.env.url["BASIC_EXAMPLE"]}>Another Example</Link>
<Link href="https://github.com/prevwong/craft.js">Github</Link>
<Link href="https://prevwong.github.io/craft.js/r/docs/overview">Documentation</Link>
<Link href={process.env.url["DOCUMENTATION"]}>Documentation</Link>
</div>
<div className="flex">
<Btn
Expand Down
6 changes: 5 additions & 1 deletion packages/examples/landing/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const withPlugins = require('next-compose-plugins');
const withCSS = require('@zeit/next-css')
const config = require("../../../config");

module.exports = withPlugins([
[withCSS]
], {
assetPrefix: ''
assetPrefix: '',
env: {
url: config.url
}
});

0 comments on commit 912e743

Please sign in to comment.