Skip to content

Commit a143c35

Browse files
committed
chore: Added tmp_dir path to the VPN logs
1 parent 83c7de3 commit a143c35

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

dist_main/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25410,9 +25410,10 @@ const run = (callback) => {
2541025410
const configFileName = "config.ovpn";
2541125411
const certificate = core.getInput("certificate", { required: true });
2541225412
const certificateName = core.getInput("certificate_name", { required: true });
25413-
const configFilePath = `${tmpDir}/${configFileName}`;
25414-
const certificatePath = `${tmpDir}/${certificateName}`;
2541525413
const openVpnLog = "openvpn.log";
25414+
const configFilePath = `${tmpDir}/${configFileName}`;
25415+
const certificateFilePath = `${tmpDir}/${certificateName}`;
25416+
const logFilePath = `${tmpDir}/${openVpnLog}`;
2541625417

2541725418
// If the certificate is base64 encoded, decode it and write it to a temporary file
2541825419
exec(`echo "${configFile}" > ${configFilePath}`);
@@ -25422,10 +25423,10 @@ const run = (callback) => {
2542225423
}
2542325424

2542425425
// If the certificate is base64 encoded, decode it and write it to a temporary file
25425-
exec(`echo "${certificate}" | base64 -d > ${certificatePath}`);
25426+
exec(`echo "${certificate}" | base64 -d > ${certificateFilePath}`);
2542625427

25427-
if (!fs.existsSync(`${certificatePath}`)) {
25428-
throw new Error(`Config file not found: ${certificatePath}`);
25428+
if (!fs.existsSync(`${certificateFilePath}`)) {
25429+
throw new Error(`Config file not found: ${certificateFilePath}`);
2542925430
}
2543025431

2543125432
fs.appendFileSync(configFile, "\n# -- GHA Modified --\n");
@@ -25435,7 +25436,7 @@ const run = (callback) => {
2543525436

2543625437
try {
2543725438
exec(
25438-
`sudo openvpn --config ${configFilePath} --pkcs12 ${certificatePath} --daemon --log ${openVpnLog} --writepid openvpn.pid`,
25439+
`sudo openvpn --config ${configFilePath} --pkcs12 ${certificateFilePath} --daemon --log ${logFilePath} --writepid openvpn.pid`,
2543925440
);
2544025441
} catch (error) {
2544125442
core.error(`Error starting OpenVPN: ${error.message}`);

src/main.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ const run = (callback) => {
1212
const configFileName = "config.ovpn";
1313
const certificate = core.getInput("certificate", { required: true });
1414
const certificateName = core.getInput("certificate_name", { required: true });
15-
const configFilePath = `${tmpDir}/${configFileName}`;
16-
const certificatePath = `${tmpDir}/${certificateName}`;
1715
const openVpnLog = "openvpn.log";
16+
const configFilePath = `${tmpDir}/${configFileName}`;
17+
const certificateFilePath = `${tmpDir}/${certificateName}`;
18+
const logFilePath = `${tmpDir}/${openVpnLog}`;
1819

1920
// If the certificate is base64 encoded, decode it and write it to a temporary file
2021
exec(`echo "${configFile}" > ${configFilePath}`);
@@ -24,10 +25,10 @@ const run = (callback) => {
2425
}
2526

2627
// If the certificate is base64 encoded, decode it and write it to a temporary file
27-
exec(`echo "${certificate}" | base64 -d > ${certificatePath}`);
28+
exec(`echo "${certificate}" | base64 -d > ${certificateFilePath}`);
2829

29-
if (!fs.existsSync(`${certificatePath}`)) {
30-
throw new Error(`Config file not found: ${certificatePath}`);
30+
if (!fs.existsSync(`${certificateFilePath}`)) {
31+
throw new Error(`Config file not found: ${certificateFilePath}`);
3132
}
3233

3334
fs.appendFileSync(configFile, "\n# -- GHA Modified --\n");
@@ -37,7 +38,7 @@ const run = (callback) => {
3738

3839
try {
3940
exec(
40-
`sudo openvpn --config ${configFilePath} --pkcs12 ${certificatePath} --daemon --log ${openVpnLog} --writepid openvpn.pid`,
41+
`sudo openvpn --config ${configFilePath} --pkcs12 ${certificateFilePath} --daemon --log ${logFilePath} --writepid openvpn.pid`,
4142
);
4243
} catch (error) {
4344
core.error(`Error starting OpenVPN: ${error.message}`);

0 commit comments

Comments
 (0)