faint-ocean-92094
01/30/2023, 8:39 PMon('task', {
executeSql (sql, ...args) {
return new Promise(async (resolve, reject)) => {
try {
let connection = await mysqlssh.connect(
{
host: "thisismyhostthatImnotsharing"
user: "supersecretuser"
privateKey: fs.readFileSync('cypress/fixtures/bd-ssh-key/id_rsa')
},
{
host: "mysqlhost"
user: "mysqluser"
password: "mysqlpassword"
database: "mysqlDatabase"
});
let result = await connection.promise().query(sql, args);
mysqlssh.close();
resolve(result[0][0]);
} catch (err) {
reject(err);
}
});
}),
})
This is working perfectly fine locally because I have my SSH key file in the provided location privateKey: fs.readFileSync('cypress/fixtures/bd-ssh-key/id_rsa')
The problem is that I can't commit this key into the repo. And what it has been requested is that I create a github secret with this key, and call it from there using ${{ secret.SSH_KEY }} I have absolutely no idea how to do this.
I though of storing the key in a variable, and passing it on as an argument in the execution command but it didn´t work. Any ideas?echoing-tent-95037
01/30/2023, 8:45 PMfaint-ocean-92094
01/30/2023, 9:19 PMprocess.env.<variable> to get that value and use it. I'm closer thanks!nutritious-honey-65632
01/30/2023, 9:38 PMenv:
SSH_KEY: ${{ secrets.SSH_KEY }}nutritious-honey-65632
01/30/2023, 9:39 PMnutritious-honey-65632
01/30/2023, 9:45 PMCYPRESS_SSH_KEY