-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeploy.js
More file actions
32 lines (28 loc) · 786 Bytes
/
deploy.js
File metadata and controls
32 lines (28 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// deploy.js
import dotenv from 'dotenv';
dotenv.config();
import fs from 'fs';
import axios from 'axios';
const html = fs.readFileSync('./dist/index.html', 'utf8');
const SERVICE_NOW_URL = process.env.VITE_DEV_URL;
const USER = process.env.VITE_REACT_APP_USER;
const PASS = process.env.VITE_REACT_APP_PASSWORD;
const deployUrl = SERVICE_NOW_URL + process.env.VITE_DEPLOY_PATH;
console.log("Deploying to:", deployUrl);
axios.post(
`${SERVICE_NOW_URL}${process.env.VITE_DEPLOY_PATH}`,
{
property: process.env.VITE_DEPLOY_PROP,
html,
},
{
auth: {
username: USER,
password: PASS,
},
}
).then(() => {
console.log("✅ Deployed successfully!");
}).catch((err) => {
console.error("❌ Deployment failed:", err.response?.data || err.message);
});