Skip to content

Commit df31934

Browse files
committed
second wf for prod
1 parent 745a202 commit df31934

File tree

4 files changed

+259
-15
lines changed

4 files changed

+259
-15
lines changed

.github/workflows/deploy-ec2-cfde-liver-main.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,38 @@ jobs:
3737
3838
- name: Build production assets
3939
env:
40-
VUE_CLI_SERVICE_CONFIG_PATH: configs/vue.config.CFDELiver.js
40+
VUE_CLI_SERVICE_CONFIG_PATH: configs/vue.config.CFDELiver_DEV.js
4141
run: npm run deploy
4242

4343
- name: Verify build output
4444
run: |
45-
ls -la portals/CFDELiver
45+
ls -la portals/CFDELiver_DEV
4646
4747
- name: Clear target directory on EC2
4848
uses: appleboy/ssh-action@v1.0.3
4949
with:
50-
host: ${{ secrets.EC2_HOST_CFDE_LIVER }}
51-
username: ${{ secrets.EC2_USER_CFDE_LIVER }}
52-
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER }}
50+
host: ${{ secrets.EC2_HOST_CFDE_LIVER_DEV }}
51+
username: ${{ secrets.EC2_USER_CFDE_LIVER_DEV }}
52+
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER_DEV }}
5353
port: ${{ secrets.EC2_PORT || 22 }}
54-
script: rm -rf ${{ secrets.EC2_TARGET_DIR_CFDE_LIVER }}/*
54+
script: rm -rf ${{ secrets.EC2_TARGET_DIR_CFDE_LIVER_DEV }}/*
5555

5656
- name: Deploy dist to EC2
5757
uses: appleboy/scp-action@v0.1.7
5858
with:
59-
host: ${{ secrets.EC2_HOST_CFDE_LIVER }}
60-
username: ${{ secrets.EC2_USER_CFDE_LIVER }}
61-
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER }}
59+
host: ${{ secrets.EC2_HOST_CFDE_LIVER_DEV }}
60+
username: ${{ secrets.EC2_USER_CFDE_LIVER_DEV }}
61+
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER_DEV }}
6262
port: ${{ secrets.EC2_PORT || 22 }}
63-
source: portals/CFDELiver/*
64-
target: ${{ secrets.EC2_TARGET_DIR_CFDE_LIVER }}
65-
strip_components: 1
63+
source: portals/CFDELiver_DEV/*
64+
target: ${{ secrets.EC2_TARGET_DIR_CFDE_LIVER_DEV }}
65+
strip_components: 2
6666

6767
- name: Run post-deploy script
6868
uses: appleboy/ssh-action@v1.0.3
6969
with:
70-
host: ${{ secrets.EC2_HOST_CFDE_LIVER }}
71-
username: ${{ secrets.EC2_USER_CFDE_LIVER }}
72-
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER }}
70+
host: ${{ secrets.EC2_HOST_CFDE_LIVER_DEV }}
71+
username: ${{ secrets.EC2_USER_CFDE_LIVER_DEV }}
72+
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER_DEV }}
7373
port: ${{ secrets.EC2_PORT || 22 }}
7474
script: /opt/deploy/post-deploy.sh
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build and Deploy to EC2 (cfde-liver-prod)
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: deploy-ec2-cfde-liver-prod
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build-and-deploy:
17+
if: startsWith(github.ref, 'refs/tags/cfde-liver-v')
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 30
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 18
29+
30+
- name: Install dependencies
31+
run: |
32+
if [ -f package-lock.json ]; then
33+
npm ci
34+
else
35+
npm install
36+
fi
37+
38+
- name: Build production assets
39+
env:
40+
VUE_CLI_SERVICE_CONFIG_PATH: configs/vue.config.CFDELiver_PROD.js
41+
run: npm run deploy
42+
43+
- name: Verify build output
44+
run: |
45+
ls -la portals/CFDELiver_PROD
46+
47+
- name: Clear target directory on EC2
48+
uses: appleboy/ssh-action@v1.0.3
49+
with:
50+
host: ${{ secrets.EC2_HOST_CFDE_LIVER_PROD }}
51+
username: ${{ secrets.EC2_USER_CFDE_LIVER_PROD }}
52+
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER_PROD }}
53+
port: ${{ secrets.EC2_PORT || 22 }}
54+
script: rm -rf ${{ secrets.EC2_TARGET_DIR_CFDE_LIVER_PROD }}/*
55+
56+
- name: Deploy dist to EC2
57+
uses: appleboy/scp-action@v0.1.7
58+
with:
59+
host: ${{ secrets.EC2_HOST_CFDE_LIVER_PROD }}
60+
username: ${{ secrets.EC2_USER_CFDE_LIVER_PROD }}
61+
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER_PROD }}
62+
port: ${{ secrets.EC2_PORT || 22 }}
63+
source: portals/CFDELiver_PROD/*
64+
target: ${{ secrets.EC2_TARGET_DIR_CFDE_LIVER_PROD }}
65+
strip_components: 2
66+
67+
- name: Run post-deploy script
68+
uses: appleboy/ssh-action@v1.0.3
69+
with:
70+
host: ${{ secrets.EC2_HOST_CFDE_LIVER_PROD }}
71+
username: ${{ secrets.EC2_USER_CFDE_LIVER_PROD }}
72+
key: ${{ secrets.EC2_SSH_KEY_CFDE_LIVER_PROD }}
73+
port: ${{ secrets.EC2_PORT || 22 }}
74+
script: /opt/deploy/post-deploy.sh
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/* We define all the pages first in an object that can be modified BEFORE being
2+
* exported so we can add/remove pages based on build type.
3+
*/
4+
5+
let pages = {
6+
index: {
7+
entry: "src/portals/CFDELiver/views/Index/main.js",
8+
template: "src/portals/CFDELiver/views/index.html",
9+
filename: "index.html",
10+
title: "Home",
11+
chunks: ["chunk-vendors", "chunk-common", "index"],
12+
},
13+
page404: {
14+
entry: "src/views/404/main.js",
15+
template: "src/portals/CFDELiver/index.html",
16+
filename: "404.html",
17+
title: "Page Not Found",
18+
chunks: ["chunk-vendors", "chunk-common", "page404"],
19+
},
20+
cellatlas: {
21+
entry: "src/portals/CFDELiver/views/CellAtlas/main.js",
22+
template: "src/portals/CFDELiver/views/index.html",
23+
filename: "cell-atlas.html",
24+
title: "Cell Atlas",
25+
chunks: ["chunk-vendors", "chunk-common", "cellatlas"],
26+
},
27+
};
28+
29+
module.exports = {
30+
devServer: {
31+
writeToDisk: true, // https://webpack.js.org/configuration/dev-server/#devserverwritetodisk-
32+
},
33+
configureWebpack: (config) => {
34+
let bioindex_dev = process.env.BIOINDEX_DEV;
35+
let bioindex_host = "https://bioindex.hugeamp.org"; // production by default
36+
//set private bioindex host if variable is defined, otherwise use default
37+
let bioindex_host_private =
38+
process.env.BIOINDEX_HOST_PRIVATE || "https://bioindex.hugeamp.org";
39+
40+
if (bioindex_dev) {
41+
bioindex_host =
42+
bioindex_dev == "localhost"
43+
? "http://localhost:5000"
44+
: "https://bioindex-dev.hugeamp.org";
45+
}
46+
47+
// output which vue config file and bioindex is being used
48+
console.log(
49+
`VUE_CONFIG_PATH=${process.env.VUE_CLI_SERVICE_CONFIG_PATH}; BIOINDEX_DEV=${process.env.BIOINDEX_DEV}; using ${bioindex_host} and ${bioindex_host_private}`
50+
);
51+
52+
// add the transform rule for bioindex
53+
config.module.rules.push({
54+
test: /bioIndexUtils\.js$/,
55+
loader: "string-replace-loader",
56+
options: {
57+
search: "SERVER_IP_ADDRESS",
58+
replace: bioindex_host,
59+
flags: "g",
60+
},
61+
});
62+
63+
// add the transform rule for bioindex
64+
config.module.rules.push({
65+
test: /bioIndexUtils\.js$/,
66+
loader: "string-replace-loader",
67+
options: {
68+
search: "SERVER_IP_PRIVATE",
69+
replace: bioindex_host_private,
70+
flags: "g",
71+
},
72+
});
73+
74+
// create inline maps for dev builds
75+
if (process.env.NODE_ENV !== "production") {
76+
//config.devtool = "inline-source-map";
77+
78+
//https://stackoverflow.com/questions/48047150/chrome-extension-compiled-by-webpack-throws-unsafe-eval-error
79+
config.devtool = "cheap-module-source-map";
80+
}
81+
},
82+
outputDir: "portals/CFDELiver_DEV",
83+
productionSourceMap: false,
84+
pages,
85+
};
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/* We define all the pages first in an object that can be modified BEFORE being
2+
* exported so we can add/remove pages based on build type.
3+
*/
4+
5+
let pages = {
6+
index: {
7+
entry: "src/portals/CFDELiver/views/Index/main.js",
8+
template: "src/portals/CFDELiver/views/index.html",
9+
filename: "index.html",
10+
title: "Home",
11+
chunks: ["chunk-vendors", "chunk-common", "index"],
12+
},
13+
page404: {
14+
entry: "src/views/404/main.js",
15+
template: "src/portals/CFDELiver/index.html",
16+
filename: "404.html",
17+
title: "Page Not Found",
18+
chunks: ["chunk-vendors", "chunk-common", "page404"],
19+
},
20+
cellatlas: {
21+
entry: "src/portals/CFDELiver/views/CellAtlas/main.js",
22+
template: "src/portals/CFDELiver/views/index.html",
23+
filename: "cell-atlas.html",
24+
title: "Cell Atlas",
25+
chunks: ["chunk-vendors", "chunk-common", "cellatlas"],
26+
},
27+
};
28+
29+
module.exports = {
30+
devServer: {
31+
writeToDisk: true, // https://webpack.js.org/configuration/dev-server/#devserverwritetodisk-
32+
},
33+
configureWebpack: (config) => {
34+
let bioindex_dev = process.env.BIOINDEX_DEV;
35+
let bioindex_host = "https://bioindex.hugeamp.org"; // production by default
36+
//set private bioindex host if variable is defined, otherwise use default
37+
let bioindex_host_private =
38+
process.env.BIOINDEX_HOST_PRIVATE || "https://bioindex.hugeamp.org";
39+
40+
if (bioindex_dev) {
41+
bioindex_host =
42+
bioindex_dev == "localhost"
43+
? "http://localhost:5000"
44+
: "https://bioindex-dev.hugeamp.org";
45+
}
46+
47+
// output which vue config file and bioindex is being used
48+
console.log(
49+
`VUE_CONFIG_PATH=${process.env.VUE_CLI_SERVICE_CONFIG_PATH}; BIOINDEX_DEV=${process.env.BIOINDEX_DEV}; using ${bioindex_host} and ${bioindex_host_private}`
50+
);
51+
52+
// add the transform rule for bioindex
53+
config.module.rules.push({
54+
test: /bioIndexUtils\.js$/,
55+
loader: "string-replace-loader",
56+
options: {
57+
search: "SERVER_IP_ADDRESS",
58+
replace: bioindex_host,
59+
flags: "g",
60+
},
61+
});
62+
63+
// add the transform rule for bioindex
64+
config.module.rules.push({
65+
test: /bioIndexUtils\.js$/,
66+
loader: "string-replace-loader",
67+
options: {
68+
search: "SERVER_IP_PRIVATE",
69+
replace: bioindex_host_private,
70+
flags: "g",
71+
},
72+
});
73+
74+
// create inline maps for dev builds
75+
if (process.env.NODE_ENV !== "production") {
76+
//config.devtool = "inline-source-map";
77+
78+
//https://stackoverflow.com/questions/48047150/chrome-extension-compiled-by-webpack-throws-unsafe-eval-error
79+
config.devtool = "cheap-module-source-map";
80+
}
81+
},
82+
outputDir: "portals/CFDELiver_PROD",
83+
productionSourceMap: false,
84+
pages,
85+
};

0 commit comments

Comments
 (0)