Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit b5e0e5d

Browse files
Merge pull request #516 from threefoldtech/development_support_network_env
Separate network environments to be on different subdomains
2 parents 8b1988a + b74b194 commit b5e0e5d

File tree

13 files changed

+108
-15
lines changed

13 files changed

+108
-15
lines changed

.github/workflows/ci-cd.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ name: CI/CD pipeline
55
on:
66
push:
77
branches:
8-
- master
98
- development
9+
release:
10+
types: [published]
11+
1012
concurrency:
1113
# one instance of runing pipeline allowed per branch.
1214
# On master, we want all builds to complete even if merging happens faster for better reliability and to make it easier to discover at which point something broke.
1315
# on developmetn, new workflow trigger will cancel the in progress job, and start a new one..
1416
group: ${{ format('ci-{0}', github.ref) }}
15-
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
17+
cancel-in-progress: ${{ github.event_name == 'release' && github.event.release.prerelease == false }}
1618
jobs:
1719
build-and-deploy:
1820

@@ -40,8 +42,25 @@ jobs:
4042
yarn install
4143
cd ..
4244
43-
- name: Build
44-
run: yarn build:app
45+
- name: Build in case development
46+
if: ${{ github.ref == 'refs/heads/development' }}
47+
run: |
48+
VERSION=$GITHUB_SHA
49+
VERSION=${VERSION:0:7} NETWORK=dev yarn build:app
50+
51+
- name: Build in case test
52+
if: github.event.release.prerelease == true
53+
run: |
54+
VERSION=$GITHUB_REF
55+
VERSION=${VERSION:10:12} NETWORK=test yarn build:app
56+
57+
- name: Build in case main
58+
if: |
59+
github.event_name == 'release' &&
60+
github.event.release.prerelease != true
61+
run: |
62+
VERSION=$GITHUB_REF
63+
VERSION=${VERSION:10:12}NETWORK=main yarn build:app
4564
4665
- name: Copying files to staging server
4766
if: ${{ github.ref == 'refs/heads/development' }}
@@ -55,8 +74,22 @@ jobs:
5574
source: "docs/"
5675
target: "${{ secrets.DEV_REMOTE_DIR }}"
5776

58-
- name: Copying files to production server
59-
if: ${{ github.ref == 'refs/heads/master' }}
77+
- name: Copying files to testing server - Pre-release
78+
if: github.event.release.prerelease == true
79+
uses: appleboy/scp-action@master
80+
with:
81+
host: ${{ secrets.DEV_REMOTE_HOST }}
82+
username: ${{ secrets.DEV_REMOTE_USER }}
83+
key: ${{ secrets.DEV_SSH_KEY }}
84+
passphrase: ${{ secrets.DEV_SSH_KEY_PASSPHRASE }}
85+
rm: true
86+
source: "docs/"
87+
target: "${{ secrets.TEST_REMOTE_DIR }}"
88+
89+
- name: Copying files to production server - Release
90+
if: |
91+
github.event_name == 'release' &&
92+
github.event.release.prerelease != true
6093
uses: appleboy/scp-action@master
6194
with:
6295
host: ${{ secrets.PROD_REMOTE_HOST }}

easy-docs/src/App.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ export default class App extends Vue {
4545
"taiga",
4646
"owncloud",
4747
"contractslist",
48+
"disclaimer",
49+
"version",
4850
"mattermost",
51+
4952
];
5053
sidenav: ISidenav | null = null;
5154

easy-docs/src/views/Editor.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@
4848
"
4949
class="tag is-info is-light"
5050
>
51-
v1.0.0-alpha
51+
<tf-version></tf-version>
5252
</span>
5353
</aside>
5454

5555
<div class="editor__content" v-if="active >= 0">
56+
<tf-disclaimer></tf-disclaimer>
5657
<nav class="navbar" role="navigation" aria-label="main navigation">
5758
<div class="navbar-end mt-2 mb-2 mr-2" style="height: 112px">
5859
<tf-profiles></tf-profiles>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@rollup/plugin-commonjs": "^17.0.0",
1515
"@rollup/plugin-json": "^4.1.0",
1616
"@rollup/plugin-node-resolve": "^11.0.0",
17+
"@rollup/plugin-replace": "^3.0.1",
1718
"@rollup/plugin-typescript": "^8.0.0",
1819
"@tsconfig/svelte": "^2.0.0",
1920
"@types/crypto-js": "^4.0.2",

rollup.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import sveltePreprocess from 'svelte-preprocess';
66
import typescript from '@rollup/plugin-typescript';
77
import fs from 'fs';
88
import path from 'path';
9+
import replace from '@rollup/plugin-replace';
910

1011
const production = !process.env.ROLLUP_WATCH;
12+
const network = process.env.NETWORK || "dev";
1113

1214
/**
1315
*
@@ -50,7 +52,14 @@ function build(options) {
5052
sourceMap: !production,
5153
inlineSources: !production
5254
}),
53-
production && terser()
55+
production && terser(),
56+
replace({
57+
preventAssignment: true,
58+
values: {
59+
'process.env.NETWORK': `"${network}"`,
60+
'process.env.VERSION': `"${process.env.VERSION || "No version to show"}"`
61+
}
62+
})
5463
],
5564
watch: {
5665
clearScreen: false

src/elements/base/Base.wc.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import currentDeploymentStore from "../../stores/currentDeployment";
1111
import LogsInfo from "../../components/LogsInfo.svelte";
1212
import balanceStore from "../../stores/balance";
13+
import Disclaimer from "../disclaimer/Disclaimer.wc.svelte";
1314
1415
window.configs = window.configs || ({} as any);
1516
window.configs.baseConfig = baseConfigStore;
@@ -33,7 +34,6 @@
3334
</script>
3435

3536
<LogsInfo />
36-
3737
<style lang="scss" scoped>
3838
@import url("https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css");
3939
</style>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<svelte:options tag="tf-disclaimer" />
2+
<script lang="ts">
3+
const envs = {
4+
dev: { env: "development", url: "https://circles.threefold.me/project/test-tfgrid3/issues" },
5+
test: { env: "testing", url: "https://circles.threefold.me/project/test-tfgrid3/issues" },
6+
};
7+
8+
$: env = envs[process.env.NETWORK];
9+
</script>
10+
11+
{#if env}
12+
13+
<div style="padding: 15px;">
14+
<form class="box">
15+
<p class="is-size-4 has-text-weight-bold">Disclaimer</p>
16+
<p>
17+
This is a {env.env} environment. We're still ironing out the kinks. If there are any issues, please let us know
18+
<a
19+
href={env.url}
20+
target="_blank"
21+
>
22+
here.
23+
</a>
24+
</p>
25+
</form>
26+
</div>
27+
{/if}
28+
29+
<style lang="scss" scoped>
30+
@import url("https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css");
31+
</style>

src/elements/disclaimer/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./Disclaimer.wc.svelte";

src/elements/profiles/Profiles.wc.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
// prettier-ignore
4141
const fields: IFormField[] = [
4242
{ label: "Profile Name", symbol: "name", placeholder: "Profile Name", type: "text" },
43-
{ label: "Network Environment", symbol: "networkEnv", type: "select", options: [
44-
{ label: "Testnet", value: "test" },
45-
{ label: "Devnet", value: "dev" }
46-
] },
43+
// { label: "Network Environment", symbol: "networkEnv", type: "select", disabled: true, options: [
44+
// { label: "Testnet", value: "test" },
45+
// { label: "Devnet", value: "dev" }
46+
// ] },
4747
{ label: "Mnemonics", symbol: "mnemonics", placeholder: "Enter Your Mnemonics", type: "password" },
48-
// { label: "TFChain Configurations Secret", symbol: "storeSecret", placeholder: "Secret key used to encrypt your data on TFChain", type: "password" },
48+
// { label: "TFChain Configurations Secret", symbol: "storeSecret", placeholder: " Secret key used to encrypt your data on TFChain", type: "password" },
4949
{ label: "Public SSH Key", symbol: "sshKey", placeholder: "Your public SSH key will be added as default to all deployments.", type: "text" },
5050
];
5151
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<svelte:options tag="tf-version" />
2+
3+
{process.env.VERSION}
4+

src/elements/version/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./Version.wc.svelte"

src/stores/baseConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { IProfile } from "../types/Profile";
77
import getGrid from "../utils/getGrid";
88

99
const PREFIX = "v2.";
10-
const createProfile = (name = "", m = "", n = "dev", key = "") => ({ id: v4(), name, mnemonics: m, storeSecret: "", networkEnv: n, sshKey: key }); // prettier-ignore
10+
const createProfile = (name = "", m = "", n = process.env.NETWORK, key = "") => ({ id: v4(), name, mnemonics: m, storeSecret: "", networkEnv: n, sshKey: key }); // prettier-ignore
1111

1212
function createBaseConfig() {
1313
const store = writable({
@@ -167,6 +167,7 @@ function createBaseConfig() {
167167
const idx = data.profiles.findIndex((p) => p.id === data.activeProfile);
168168
const profile = data.profiles[idx] as IProfile;
169169
profile.storeSecret = data.storeSecret;
170+
profile.networkEnv = process.env.NETWORK;
170171
return profile;
171172
},
172173
};

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,14 @@
599599
is-module "^1.0.0"
600600
resolve "^1.19.0"
601601

602+
"@rollup/plugin-replace@^3.0.1":
603+
version "3.0.1"
604+
resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-3.0.1.tgz#f774550f482091719e52e9f14f67ffc0046a883d"
605+
integrity sha512-989J5oRzf3mm0pO/0djTijdfEh9U3n63BIXN5X7T4U9BP+fN4oxQ6DvDuBvFaHA6scaHQRclqmKQEkBhB7k7Hg==
606+
dependencies:
607+
"@rollup/pluginutils" "^3.1.0"
608+
magic-string "^0.25.7"
609+
602610
"@rollup/plugin-typescript@^8.0.0":
603611
version "8.3.0"
604612
resolved "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.3.0.tgz"

0 commit comments

Comments
 (0)