Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Main.ts Authentication and Env variables #71

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ const core = require('@actions/core');
const twilio = require('twilio');

async function run() {
const from = core.getInput('fromPhoneNumber');
const to = core.getInput('toPhoneNumber');
const message = core.getInput('message');
const from = core.getInput('fromPhoneNumber') || process.env.FROM_PHONE_NUMBER;
const to = core.getInput('toPhoneNumber') || process.env.TO_PHONE_NUMBER;
const message = core.getInput('messageToSend') || process.env.MESSAGE_TO_SEND;


const accountSid =
core.getInput('TWILIO_ACCOUNT_SID') || process.env.TWILIO_ACCOUNT_SID;
const apiKey = core.getInput('TWILIO_API_KEY') || process.env.TWILIO_API_KEY;
const apiSecret =
core.getInput('TWILIO_API_SECRET') || process.env.TWILIO_API_SECRET;
const authToken =
core.getInput('TWILIO_AUTH_TOKEN') || process.env.TWILIO_AUTH_TOKEN;

core.debug('Sending SMS');
const client = twilio(apiKey, apiSecret, { accountSid });
core.debug('Authenticating with Twilio');
const client = twilio(accountSid, authToken);
core.debug('Attempting to send SMS!');
const resultMessage = await client.messages.create({
from,
to,
Expand Down
Loading