[
  {
    "path": ".github/config.yml",
    "content": "newIssueWelcomeComment: |\n  Thank you so much for opening your first issue for this project! We'll try to get back to it as quickly as possible. While you are waiting...here's a random picture of a corgi (powered by [dog.ceo](https://dog.ceo))\n\n  ![picture of dog](https://images.dog.ceo/breeds/corgi-cardigan/n02113186_1447.jpg)\n\nfirstPRMergeComment: >\n  Congratulations to your first contribution to Twilio Labs!\n\n  We'd love to say thank you and send you some swag. If you are interested please fill out this form at https://twil.io/hacktoberfest-swag\n\n  If you are on the look out for more ways to contribute to open-source, \n  check out a list of some of our repositories at https://github.com/twilio/opensource.\n\n  And if you love Twilio as much as we do, make sure to check out our \n  Twilio Champions program! https://www.twilio.com/champions"
  },
  {
    "path": ".github/workflows/check.yml",
    "content": "name: Test\non:\n  [pull_request]\njobs:\n  check:\n    name: Run Tests\n    runs-on: ubuntu-latest\n    steps:\n    - name: Checkout Repository\n      uses: actions/checkout@v4\n    - name: Setup Node.js\n      uses: actions/setup-node@v4\n    - name: npm\n      run: |\n        npm run dev\n        npm run clean\n"
  },
  {
    "path": ".github/workflows/package.yml",
    "content": "on:\n  push:\n    branches:\n      - master\n\nname: Package\n\njobs:\n  check:\n    name: Package distribution file\n    runs-on: ubuntu-latest\n    steps:\n    - name: Checkout\n      uses: actions/checkout@v2\n      with:\n        ref: master\n    - name: Package\n      run: |\n        npm ci\n        npm run test\n    - name: Commit\n      run: |\n        git config --global user.name \"GitHub Actions\"\n        git add dist/\n        git add node_modules/\n        git commit -m \"chore: Update dist\" || echo \"No changes to commit\"\n        git push origin HEAD:master\n"
  },
  {
    "path": ".gitignore",
    "content": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n*.lcov\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\n# node_modules/ this is a GitHub Action, we need to not remove node_modules\njspm_packages/\n\n# TypeScript v1 declaration files\ntypings/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Microbundle cache\n.rpt2_cache/\n.rts2_cache_cjs/\n.rts2_cache_es/\n.rts2_cache_umd/\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variables file\n.env\n.env.test\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n\n# Next.js build output\n.next\n\n# Nuxt.js build / generate output\n.nuxt\n# dist\n\n# Gatsby files\n.cache/\n# Comment in the public line in if your project uses Gatsby and not Next.js\n# https://nextjs.org/blog/next-9-1#public-directory-support\n# public\n\n# vuepress build output\n.vuepress/dist\n\n# Serverless directories\n.serverless/\n\n# FuseBox cache\n.fusebox/\n\n# DynamoDB Local files\n.dynamodb/\n\n# TernJS port file\n.tern-port\n\n# Stores VSCode versions used for testing VSCode extensions\n.vscode-test"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019 Twilio Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Twilio SMS GitHub Action\n\nSend an SMS from GitHub Actions.\n\n## Prerequisites\n\n- A Twilio Account. [Sign up for free](https://www.twilio.com/try-twilio)\n- A [Twilio Auth Token](https://www.twilio.com/docs/iam/api/authtoken)\n- A [Registered Phone Number](https://www.twilio.com/docs/phone-numbers/regulatory/faq) \n\n## Usage\n\n1. Set up your credentials as secrets in your repository settings using `TWILIO_ACCOUNT_SID`, `TWILIO_AUTH_TOKEN`, `TO_PHONE_NUMBER`, `FROM_PHONE_NUMBER` \n\n2. Add the following to your workflow\n\n```yml\nname: Twilio Send\non:\n  workflow_dispatch: # allows you to manually trigger the workflow\n  schedule: # runs on a cron, nightly\n    - cron: 0 0 * * * \nenv:\n    TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}\n    TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}\n    TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }}\npermissions:\n  contents: read\njobs:\n  send:\n    runs-on: ubuntu-latest\n    steps:\n      - name: 'Sending SMS Notification'\n        uses: twilio-labs/actions-sms@v1\n        with:\n          FROM_PHONE_NUMBER: ${{ secrets.FROM_PHONE_NUMBER }} \n          TO_PHONE_NUMBER: ${{ secrets.TO_PHONE_NUMBER }} \n          message: 'Hello from Twilio'\n```\n\n## Inputs\n\n### `FROM_PHONE_NUMBER`\n\n**Required** Phone number in your Twilio account to send the SMS from\n\n### `TO_PHONE_NUMBER`\n\n**Required** Phone number to send the SMS to\n\n### `message`\n\n**Required** The message you want to send\n\n### `TWILIO_ACCOUNT_SID`\n\nA Twilio Account SID. Can alternatively be stored in environment\n\n### `TWILIO_AUTH_TOKEN`\n\nA Twilio Auth Token. Can alternatively be stored in environment\n\n## Outputs\n\n### `messageSid`\n\nThe SID of the [message resource](https://www.twilio.com/docs/sms/api/message-resource#message-properties) associated with the SMS sent.\n\n## Contributing\n\n## Third Party Licenses\n\nThis GitHub Action uses a couple of Node.js modules to work.\n\nLicense and other copyright information for each module are included in the release branch of each action version under `node_modules/{module}`.\n\nMore information for each package can be found at `https://www.npmjs.com/package/{package}`\n\n## License\n\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)\n"
  },
  {
    "path": "action-sms.test.js",
    "content": "const core = require(\"@actions/core\");\nconst twilio = require(\"twilio\");\nconst run = require(\"./dist/main.js\");\n\njest.mock(\"@actions/core\");\njest.mock(\"twilio\");\n\ntest(\"Log failures\", async () => {\n  const errorMessage = \"Error from twilio\";\n\n  twilio.mockImplementation(() => {\n    throw new Error(errorMessage);\n  });\n\n  await run();\n\n  expect(core.error.mock.calls).toEqual(\n    expect.arrayContaining([[\"Failed to send message\", errorMessage]])\n  );\n\n  expect(core.setFailed.mock.calls).toEqual(\n    expect.arrayContaining([[errorMessage]])\n  );\n});\n\ntest(\"Returns message sid\", async () => {\n  const sid = \"ID123\";\n\n  twilio.mockReturnValue({\n    messages: {\n      create: () => ({ sid })\n    }\n  });\n\n  const { sid: resultSid } = await run();\n  expect(resultSid).toEqual(sid);\n});\n"
  },
  {
    "path": "action.yml",
    "content": "name: 'Twilio SMS'\nauthor: 'Twilio Labs'\ndescription: 'Send an SMS from GitHub Actions using Twilio Programmable SMS'\ninputs:\n  FROM_PHONE_NUMBER:\n    description: 'Phone number in your Twilio account to send the SMS from'\n    required: true\n  TO_PHONE_NUMBER:\n    description: 'Phone number to send the SMS to'\n    required: true\n  message:\n    description: 'The message you want to send'\n    required: true\n  TWILIO_ACCOUNT_SID:\n    description: 'A Twilio Account SID.'\n    required: true\n  TWILIO_AUTH_TOKEN:\n    description: 'A Twilio Auth Token.'\n    required: true\noutputs:\n  messageSid:\n    description: 'The Twilio Message SID'\nruns:\n  using: 'node16'\n  main: 'dist/main.js'\nbranding:\n  color: 'red'\n  icon: 'message-circle'\n"
  },
  {
    "path": "dist/main.js",
    "content": "\"use strict\";\nconst core = require('@actions/core');\nconst twilio = require('twilio');\nasync function run() {\n    const from = core.getInput('fromPhoneNumber') || process.env.FROM_PHONE_NUMBER;\n    const to = core.getInput('toPhoneNumber') || process.env.TO_PHONE_NUMBER;\n    const message = core.getInput('messageToSend') || process.env.MESSAGE_TO_SEND;\n    const accountSid = core.getInput('TWILIO_ACCOUNT_SID') || process.env.TWILIO_ACCOUNT_SID;\n    const authToken = core.getInput('TWILIO_AUTH_TOKEN') || process.env.TWILIO_AUTH_TOKEN;\n    core.debug('Authenticating with Twilio');\n    const client = twilio(accountSid, authToken);\n    core.debug('Attempting to send SMS!');\n    const resultMessage = await client.messages.create({\n        from,\n        to,\n        body: message,\n    });\n    core.debug('SMS sent!');\n    core.setOutput('messageSid', resultMessage.sid);\n    return resultMessage;\n}\nasync function execute() {\n    try {\n        return await run(); //@ts-ignore\n    }\n    catch ({ message }) {\n        core.error('Failed to send message', message);\n        core.setFailed(message);\n    }\n}\nmodule.exports = execute;\nexecute();\n"
  },
  {
    "path": "jest.config.js",
    "content": "// For a detailed explanation regarding each configuration property, visit:\n// https://jestjs.io/docs/en/configuration.html\n\nmodule.exports = {\n  // All imported modules in your tests should be mocked automatically\n  // automock: false,\n\n  // Stop running tests after `n` failures\n  // bail: 0,\n\n  // Respect \"browser\" field in package.json when resolving modules\n  // browser: false,\n\n  // The directory where Jest should store its cached dependency information\n  // cacheDirectory: \"/private/var/folders/lb/7ldkbf557vn8zp42341vhd0m0000gn/T/jest_dx\",\n\n  // Automatically clear mock calls and instances between every test\n  clearMocks: true,\n\n  // Indicates whether the coverage information should be collected while executing the test\n  // collectCoverage: false,\n\n  // An array of glob patterns indicating a set of files for which coverage information should be collected\n  // collectCoverageFrom: null,\n\n  // The directory where Jest should output its coverage files\n  // coverageDirectory: null,\n\n  // An array of regexp pattern strings used to skip coverage collection\n  // coveragePathIgnorePatterns: [\n  //   \"/node_modules/\"\n  // ],\n\n  // A list of reporter names that Jest uses when writing coverage reports\n  // coverageReporters: [\n  //   \"json\",\n  //   \"text\",\n  //   \"lcov\",\n  //   \"clover\"\n  // ],\n\n  // An object that configures minimum threshold enforcement for coverage results\n  // coverageThreshold: null,\n\n  // A path to a custom dependency extractor\n  // dependencyExtractor: null,\n\n  // Make calling deprecated APIs throw helpful error messages\n  // errorOnDeprecated: false,\n\n  // Force coverage collection from ignored files using an array of glob patterns\n  // forceCoverageMatch: [],\n\n  // A path to a module which exports an async function that is triggered once before all test suites\n  // globalSetup: null,\n\n  // A path to a module which exports an async function that is triggered once after all test suites\n  // globalTeardown: null,\n\n  // A set of global variables that need to be available in all test environments\n  // globals: {},\n\n  // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.\n  // maxWorkers: \"50%\",\n\n  // An array of directory names to be searched recursively up from the requiring module's location\n  // moduleDirectories: [\n  //   \"node_modules\"\n  // ],\n\n  // An array of file extensions your modules use\n  // moduleFileExtensions: [\n  //   \"js\",\n  //   \"json\",\n  //   \"jsx\",\n  //   \"ts\",\n  //   \"tsx\",\n  //   \"node\"\n  // ],\n\n  // A map from regular expressions to module names that allow to stub out resources with a single module\n  // moduleNameMapper: {},\n\n  // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader\n  // modulePathIgnorePatterns: [],\n\n  // Activates notifications for test results\n  // notify: false,\n\n  // An enum that specifies notification mode. Requires { notify: true }\n  // notifyMode: \"failure-change\",\n\n  // A preset that is used as a base for Jest's configuration\n  // preset: null,\n\n  // Run tests from one or more projects\n  // projects: null,\n\n  // Use this configuration option to add custom reporters to Jest\n  // reporters: undefined,\n\n  // Automatically reset mock state between every test\n  // resetMocks: false,\n\n  // Reset the module registry before running each individual test\n  // resetModules: false,\n\n  // A path to a custom resolver\n  // resolver: null,\n\n  // Automatically restore mock state between every test\n  // restoreMocks: false,\n\n  // The root directory that Jest should scan for tests and modules within\n  // rootDir: null,\n\n  // A list of paths to directories that Jest should use to search for files in\n  // roots: [\n  //   \"<rootDir>\"\n  // ],\n\n  // Allows you to use a custom runner instead of Jest's default test runner\n  // runner: \"jest-runner\",\n\n  // The paths to modules that run some code to configure or set up the testing environment before each test\n  // setupFiles: [],\n\n  // A list of paths to modules that run some code to configure or set up the testing framework before each test\n  // setupFilesAfterEnv: [],\n\n  // A list of paths to snapshot serializer modules Jest should use for snapshot testing\n  // snapshotSerializers: [],\n\n  // The test environment that will be used for testing\n  testEnvironment: \"node\",\n\n  // Options that will be passed to the testEnvironment\n  // testEnvironmentOptions: {},\n\n  // Adds a location field to test results\n  // testLocationInResults: false,\n\n  // The glob patterns Jest uses to detect test files\n  // testMatch: [\n  //   \"**/__tests__/**/*.[jt]s?(x)\",\n  //   \"**/?(*.)+(spec|test).[tj]s?(x)\"\n  // ],\n\n  // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped\n  // testPathIgnorePatterns: [\n  //   \"/node_modules/\"\n  // ],\n\n  // The regexp pattern or array of patterns that Jest uses to detect test files\n  // testRegex: [],\n\n  // This option allows the use of a custom results processor\n  // testResultsProcessor: null,\n\n  // This option allows use of a custom test runner\n  // testRunner: \"jasmine2\",\n\n  // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href\n  // testURL: \"http://localhost\",\n\n  // Setting this value to \"fake\" allows the use of fake timers for functions such as \"setTimeout\"\n  // timers: \"real\",\n\n  // A map from regular expressions to paths to transformers\n  // transform: null,\n\n  // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation\n  // transformIgnorePatterns: [\n  //   \"/node_modules/\"\n  // ],\n\n  // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them\n  // unmockedModulePathPatterns: undefined,\n\n  // Indicates whether each individual test should be reported during the run\n  // verbose: null,\n\n  // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode\n  // watchPathIgnorePatterns: [],\n\n  // Whether to use watchman for file crawling\n  // watchman: true,\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"@twilio-labs/actions-sms\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Send an SMS through GitHub Actions\",\n  \"main\": \"dist/main.js\",\n  \"scripts\": {\n    \"build\": \"tsc\",\n    \"test\": \"npm run build && jest\",\n    \"install:dev\": \"rm -rf node_modules && npm install\",\n    \"install:prod\": \"rm -rf node_modules && npm install --omit=dev\",\n    \"dev\": \"npm run install:dev && npm run test\",\n    \"clean\": \"npm run install:prod\",\n    \"dependencyUpdate\": \"npx npm-check-updates -u && npm install\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/twilio-labs/actions-sms.git\"\n  },\n  \"keywords\": [\n    \"github\",\n    \"actions\",\n    \"twilio\",\n    \"sms\"\n  ],\n  \"author\": \"Dominik Kundel <dkundel@twilio.com> (https://twilio.com/labs)\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/twilio-labs/actions-sms/issues\"\n  },\n  \"homepage\": \"https://github.com/twilio-labs/actions-sms#readme\",\n  \"dependencies\": {\n    \"@actions/core\": \"^1.11.1\",\n    \"twilio\": \"^5.3.7\"\n  },\n  \"devDependencies\": {\n    \"@types/node\": \"^22.10.1\",\n    \"jest\": \"^29.7.0\",\n    \"typescript\": \"^5.7.2\"\n  }\n}\n"
  },
  {
    "path": "src/main.ts",
    "content": "const core = require('@actions/core');\nconst twilio = require('twilio');\n\nasync function run() {\n  const from = core.getInput('fromPhoneNumber') || process.env.FROM_PHONE_NUMBER;\n  const to = core.getInput('toPhoneNumber') || process.env.TO_PHONE_NUMBER;\n  const message = core.getInput('messageToSend') || process.env.MESSAGE_TO_SEND;\n\n  \n  const accountSid =\n    core.getInput('TWILIO_ACCOUNT_SID') || process.env.TWILIO_ACCOUNT_SID;\n  const authToken =\n    core.getInput('TWILIO_AUTH_TOKEN') || process.env.TWILIO_AUTH_TOKEN;\n\n  core.debug('Authenticating with Twilio');\n  const client = twilio(accountSid, authToken);\n  core.debug('Attempting to send SMS!');\n  const resultMessage = await client.messages.create({\n    from,\n    to,\n    body: message,\n  });\n  core.debug('SMS sent!');\n\n  core.setOutput('messageSid', resultMessage.sid);\n\n  return resultMessage;\n}\n\nasync function execute() {\n  try {\n    return await run(); //@ts-ignore\n  } catch({ message }) { \n    core.error('Failed to send message', message);\n    core.setFailed(message);\n  }\n}\n\nmodule.exports = execute;\n\nexecute();\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"outDir\": \"./dist\",\n    \"target\": \"es2018\",\n    \"strict\": true,\n    \"strictNullChecks\": true,\n    \"alwaysStrict\": true,\n    \"moduleResolution\": \"node\",\n    \"skipLibCheck\": true\n  },\n  \"types\": [\"node\"],\n  \"typeRoots\": [\"./node_modules/@types\"],\n  \"include\": [\n    \"./src/**/*\"\n  ],\n  \"exclude\": [\n    \"node_modules\",\n    \"./node_modules\",\n    \"./node_modules/*\",\n    \"./node_modules/@types/node/index.d.ts\"\n  ]\n}\n"
  }
]