Full Code of twilio-labs/actions-sms for AI

main 3ed73c8f1c2c cached
13 files
18.0 KB
4.9k tokens
4 symbols
1 requests
Download .txt
Repository: twilio-labs/actions-sms
Branch: main
Commit: 3ed73c8f1c2c
Files: 13
Total size: 18.0 KB

Directory structure:
gitextract_8t8w1wx4/

├── .github/
│   ├── config.yml
│   └── workflows/
│       ├── check.yml
│       └── package.yml
├── .gitignore
├── LICENSE
├── README.md
├── action-sms.test.js
├── action.yml
├── dist/
│   └── main.js
├── jest.config.js
├── package.json
├── src/
│   └── main.ts
└── tsconfig.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/config.yml
================================================
newIssueWelcomeComment: |
  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))

  ![picture of dog](https://images.dog.ceo/breeds/corgi-cardigan/n02113186_1447.jpg)

firstPRMergeComment: >
  Congratulations to your first contribution to Twilio Labs!

  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

  If you are on the look out for more ways to contribute to open-source, 
  check out a list of some of our repositories at https://github.com/twilio/opensource.

  And if you love Twilio as much as we do, make sure to check out our 
  Twilio Champions program! https://www.twilio.com/champions

================================================
FILE: .github/workflows/check.yml
================================================
name: Test
on:
  [pull_request]
jobs:
  check:
    name: Run Tests
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Repository
      uses: actions/checkout@v4
    - name: Setup Node.js
      uses: actions/setup-node@v4
    - name: npm
      run: |
        npm run dev
        npm run clean


================================================
FILE: .github/workflows/package.yml
================================================
on:
  push:
    branches:
      - master

name: Package

jobs:
  check:
    name: Package distribution file
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
      with:
        ref: master
    - name: Package
      run: |
        npm ci
        npm run test
    - name: Commit
      run: |
        git config --global user.name "GitHub Actions"
        git add dist/
        git add node_modules/
        git commit -m "chore: Update dist" || echo "No changes to commit"
        git push origin HEAD:master


================================================
FILE: .gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
# node_modules/ this is a GitHub Action, we need to not remove node_modules
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
# dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2019 Twilio Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# Twilio SMS GitHub Action

Send an SMS from GitHub Actions.

## Prerequisites

- A Twilio Account. [Sign up for free](https://www.twilio.com/try-twilio)
- A [Twilio Auth Token](https://www.twilio.com/docs/iam/api/authtoken)
- A [Registered Phone Number](https://www.twilio.com/docs/phone-numbers/regulatory/faq) 

## Usage

1. Set up your credentials as secrets in your repository settings using `TWILIO_ACCOUNT_SID`, `TWILIO_AUTH_TOKEN`, `TO_PHONE_NUMBER`, `FROM_PHONE_NUMBER` 

2. Add the following to your workflow

```yml
name: Twilio Send
on:
  workflow_dispatch: # allows you to manually trigger the workflow
  schedule: # runs on a cron, nightly
    - cron: 0 0 * * * 
env:
    TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
    TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
    TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }}
permissions:
  contents: read
jobs:
  send:
    runs-on: ubuntu-latest
    steps:
      - name: 'Sending SMS Notification'
        uses: twilio-labs/actions-sms@v1
        with:
          FROM_PHONE_NUMBER: ${{ secrets.FROM_PHONE_NUMBER }} 
          TO_PHONE_NUMBER: ${{ secrets.TO_PHONE_NUMBER }} 
          message: 'Hello from Twilio'
```

## Inputs

### `FROM_PHONE_NUMBER`

**Required** Phone number in your Twilio account to send the SMS from

### `TO_PHONE_NUMBER`

**Required** Phone number to send the SMS to

### `message`

**Required** The message you want to send

### `TWILIO_ACCOUNT_SID`

A Twilio Account SID. Can alternatively be stored in environment

### `TWILIO_AUTH_TOKEN`

A Twilio Auth Token. Can alternatively be stored in environment

## Outputs

### `messageSid`

The SID of the [message resource](https://www.twilio.com/docs/sms/api/message-resource#message-properties) associated with the SMS sent.

## Contributing

## Third Party Licenses

This GitHub Action uses a couple of Node.js modules to work.

License and other copyright information for each module are included in the release branch of each action version under `node_modules/{module}`.

More information for each package can be found at `https://www.npmjs.com/package/{package}`

## License

[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)


================================================
FILE: action-sms.test.js
================================================
const core = require("@actions/core");
const twilio = require("twilio");
const run = require("./dist/main.js");

jest.mock("@actions/core");
jest.mock("twilio");

test("Log failures", async () => {
  const errorMessage = "Error from twilio";

  twilio.mockImplementation(() => {
    throw new Error(errorMessage);
  });

  await run();

  expect(core.error.mock.calls).toEqual(
    expect.arrayContaining([["Failed to send message", errorMessage]])
  );

  expect(core.setFailed.mock.calls).toEqual(
    expect.arrayContaining([[errorMessage]])
  );
});

test("Returns message sid", async () => {
  const sid = "ID123";

  twilio.mockReturnValue({
    messages: {
      create: () => ({ sid })
    }
  });

  const { sid: resultSid } = await run();
  expect(resultSid).toEqual(sid);
});


================================================
FILE: action.yml
================================================
name: 'Twilio SMS'
author: 'Twilio Labs'
description: 'Send an SMS from GitHub Actions using Twilio Programmable SMS'
inputs:
  FROM_PHONE_NUMBER:
    description: 'Phone number in your Twilio account to send the SMS from'
    required: true
  TO_PHONE_NUMBER:
    description: 'Phone number to send the SMS to'
    required: true
  message:
    description: 'The message you want to send'
    required: true
  TWILIO_ACCOUNT_SID:
    description: 'A Twilio Account SID.'
    required: true
  TWILIO_AUTH_TOKEN:
    description: 'A Twilio Auth Token.'
    required: true
outputs:
  messageSid:
    description: 'The Twilio Message SID'
runs:
  using: 'node16'
  main: 'dist/main.js'
branding:
  color: 'red'
  icon: 'message-circle'


================================================
FILE: dist/main.js
================================================
"use strict";
const core = require('@actions/core');
const twilio = require('twilio');
async function run() {
    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 authToken = core.getInput('TWILIO_AUTH_TOKEN') || process.env.TWILIO_AUTH_TOKEN;
    core.debug('Authenticating with Twilio');
    const client = twilio(accountSid, authToken);
    core.debug('Attempting to send SMS!');
    const resultMessage = await client.messages.create({
        from,
        to,
        body: message,
    });
    core.debug('SMS sent!');
    core.setOutput('messageSid', resultMessage.sid);
    return resultMessage;
}
async function execute() {
    try {
        return await run(); //@ts-ignore
    }
    catch ({ message }) {
        core.error('Failed to send message', message);
        core.setFailed(message);
    }
}
module.exports = execute;
execute();


================================================
FILE: jest.config.js
================================================
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
  // All imported modules in your tests should be mocked automatically
  // automock: false,

  // Stop running tests after `n` failures
  // bail: 0,

  // Respect "browser" field in package.json when resolving modules
  // browser: false,

  // The directory where Jest should store its cached dependency information
  // cacheDirectory: "/private/var/folders/lb/7ldkbf557vn8zp42341vhd0m0000gn/T/jest_dx",

  // Automatically clear mock calls and instances between every test
  clearMocks: true,

  // Indicates whether the coverage information should be collected while executing the test
  // collectCoverage: false,

  // An array of glob patterns indicating a set of files for which coverage information should be collected
  // collectCoverageFrom: null,

  // The directory where Jest should output its coverage files
  // coverageDirectory: null,

  // An array of regexp pattern strings used to skip coverage collection
  // coveragePathIgnorePatterns: [
  //   "/node_modules/"
  // ],

  // A list of reporter names that Jest uses when writing coverage reports
  // coverageReporters: [
  //   "json",
  //   "text",
  //   "lcov",
  //   "clover"
  // ],

  // An object that configures minimum threshold enforcement for coverage results
  // coverageThreshold: null,

  // A path to a custom dependency extractor
  // dependencyExtractor: null,

  // Make calling deprecated APIs throw helpful error messages
  // errorOnDeprecated: false,

  // Force coverage collection from ignored files using an array of glob patterns
  // forceCoverageMatch: [],

  // A path to a module which exports an async function that is triggered once before all test suites
  // globalSetup: null,

  // A path to a module which exports an async function that is triggered once after all test suites
  // globalTeardown: null,

  // A set of global variables that need to be available in all test environments
  // globals: {},

  // 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.
  // maxWorkers: "50%",

  // An array of directory names to be searched recursively up from the requiring module's location
  // moduleDirectories: [
  //   "node_modules"
  // ],

  // An array of file extensions your modules use
  // moduleFileExtensions: [
  //   "js",
  //   "json",
  //   "jsx",
  //   "ts",
  //   "tsx",
  //   "node"
  // ],

  // A map from regular expressions to module names that allow to stub out resources with a single module
  // moduleNameMapper: {},

  // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
  // modulePathIgnorePatterns: [],

  // Activates notifications for test results
  // notify: false,

  // An enum that specifies notification mode. Requires { notify: true }
  // notifyMode: "failure-change",

  // A preset that is used as a base for Jest's configuration
  // preset: null,

  // Run tests from one or more projects
  // projects: null,

  // Use this configuration option to add custom reporters to Jest
  // reporters: undefined,

  // Automatically reset mock state between every test
  // resetMocks: false,

  // Reset the module registry before running each individual test
  // resetModules: false,

  // A path to a custom resolver
  // resolver: null,

  // Automatically restore mock state between every test
  // restoreMocks: false,

  // The root directory that Jest should scan for tests and modules within
  // rootDir: null,

  // A list of paths to directories that Jest should use to search for files in
  // roots: [
  //   "<rootDir>"
  // ],

  // Allows you to use a custom runner instead of Jest's default test runner
  // runner: "jest-runner",

  // The paths to modules that run some code to configure or set up the testing environment before each test
  // setupFiles: [],

  // A list of paths to modules that run some code to configure or set up the testing framework before each test
  // setupFilesAfterEnv: [],

  // A list of paths to snapshot serializer modules Jest should use for snapshot testing
  // snapshotSerializers: [],

  // The test environment that will be used for testing
  testEnvironment: "node",

  // Options that will be passed to the testEnvironment
  // testEnvironmentOptions: {},

  // Adds a location field to test results
  // testLocationInResults: false,

  // The glob patterns Jest uses to detect test files
  // testMatch: [
  //   "**/__tests__/**/*.[jt]s?(x)",
  //   "**/?(*.)+(spec|test).[tj]s?(x)"
  // ],

  // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
  // testPathIgnorePatterns: [
  //   "/node_modules/"
  // ],

  // The regexp pattern or array of patterns that Jest uses to detect test files
  // testRegex: [],

  // This option allows the use of a custom results processor
  // testResultsProcessor: null,

  // This option allows use of a custom test runner
  // testRunner: "jasmine2",

  // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
  // testURL: "http://localhost",

  // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
  // timers: "real",

  // A map from regular expressions to paths to transformers
  // transform: null,

  // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
  // transformIgnorePatterns: [
  //   "/node_modules/"
  // ],

  // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
  // unmockedModulePathPatterns: undefined,

  // Indicates whether each individual test should be reported during the run
  // verbose: null,

  // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
  // watchPathIgnorePatterns: [],

  // Whether to use watchman for file crawling
  // watchman: true,
};


================================================
FILE: package.json
================================================
{
  "name": "@twilio-labs/actions-sms",
  "version": "1.0.0",
  "description": "Send an SMS through GitHub Actions",
  "main": "dist/main.js",
  "scripts": {
    "build": "tsc",
    "test": "npm run build && jest",
    "install:dev": "rm -rf node_modules && npm install",
    "install:prod": "rm -rf node_modules && npm install --omit=dev",
    "dev": "npm run install:dev && npm run test",
    "clean": "npm run install:prod",
    "dependencyUpdate": "npx npm-check-updates -u && npm install"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/twilio-labs/actions-sms.git"
  },
  "keywords": [
    "github",
    "actions",
    "twilio",
    "sms"
  ],
  "author": "Dominik Kundel <dkundel@twilio.com> (https://twilio.com/labs)",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/twilio-labs/actions-sms/issues"
  },
  "homepage": "https://github.com/twilio-labs/actions-sms#readme",
  "dependencies": {
    "@actions/core": "^1.11.1",
    "twilio": "^5.3.7"
  },
  "devDependencies": {
    "@types/node": "^22.10.1",
    "jest": "^29.7.0",
    "typescript": "^5.7.2"
  }
}


================================================
FILE: src/main.ts
================================================
const core = require('@actions/core');
const twilio = require('twilio');

async function run() {
  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 authToken =
    core.getInput('TWILIO_AUTH_TOKEN') || process.env.TWILIO_AUTH_TOKEN;

  core.debug('Authenticating with Twilio');
  const client = twilio(accountSid, authToken);
  core.debug('Attempting to send SMS!');
  const resultMessage = await client.messages.create({
    from,
    to,
    body: message,
  });
  core.debug('SMS sent!');

  core.setOutput('messageSid', resultMessage.sid);

  return resultMessage;
}

async function execute() {
  try {
    return await run(); //@ts-ignore
  } catch({ message }) { 
    core.error('Failed to send message', message);
    core.setFailed(message);
  }
}

module.exports = execute;

execute();


================================================
FILE: tsconfig.json
================================================
{
  "compilerOptions": {
    "module": "commonjs",
    "outDir": "./dist",
    "target": "es2018",
    "strict": true,
    "strictNullChecks": true,
    "alwaysStrict": true,
    "moduleResolution": "node",
    "skipLibCheck": true
  },
  "types": ["node"],
  "typeRoots": ["./node_modules/@types"],
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "node_modules",
    "./node_modules",
    "./node_modules/*",
    "./node_modules/@types/node/index.d.ts"
  ]
}
Download .txt
gitextract_8t8w1wx4/

├── .github/
│   ├── config.yml
│   └── workflows/
│       ├── check.yml
│       └── package.yml
├── .gitignore
├── LICENSE
├── README.md
├── action-sms.test.js
├── action.yml
├── dist/
│   └── main.js
├── jest.config.js
├── package.json
├── src/
│   └── main.ts
└── tsconfig.json
Download .txt
SYMBOL INDEX (4 symbols across 2 files)

FILE: dist/main.js
  function run (line 4) | async function run() {
  function execute (line 22) | async function execute() {

FILE: src/main.ts
  function run (line 4) | async function run() {
  function execute (line 30) | async function execute() {
Condensed preview — 13 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (20K chars).
[
  {
    "path": ".github/config.yml",
    "chars": 850,
    "preview": "newIssueWelcomeComment: |\n  Thank you so much for opening your first issue for this project! We'll try to get back to it"
  },
  {
    "path": ".github/workflows/check.yml",
    "chars": 300,
    "preview": "name: Test\non:\n  [pull_request]\njobs:\n  check:\n    name: Run Tests\n    runs-on: ubuntu-latest\n    steps:\n    - name: Che"
  },
  {
    "path": ".github/workflows/package.yml",
    "chars": 549,
    "preview": "on:\n  push:\n    branches:\n      - master\n\nname: Package\n\njobs:\n  check:\n    name: Package distribution file\n    runs-on:"
  },
  {
    "path": ".gitignore",
    "chars": 1745,
    "preview": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# Diagnostic reports (https://nodejs."
  },
  {
    "path": "LICENSE",
    "chars": 1068,
    "preview": "MIT License\n\nCopyright (c) 2019 Twilio Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
  },
  {
    "path": "README.md",
    "chars": 2237,
    "preview": "# Twilio SMS GitHub Action\n\nSend an SMS from GitHub Actions.\n\n## Prerequisites\n\n- A Twilio Account. [Sign up for free](h"
  },
  {
    "path": "action-sms.test.js",
    "chars": 787,
    "preview": "const core = require(\"@actions/core\");\nconst twilio = require(\"twilio\");\nconst run = require(\"./dist/main.js\");\n\njest.mo"
  },
  {
    "path": "action.yml",
    "chars": 733,
    "preview": "name: 'Twilio SMS'\nauthor: 'Twilio Labs'\ndescription: 'Send an SMS from GitHub Actions using Twilio Programmable SMS'\nin"
  },
  {
    "path": "dist/main.js",
    "chars": 1146,
    "preview": "\"use strict\";\nconst core = require('@actions/core');\nconst twilio = require('twilio');\nasync function run() {\n    const "
  },
  {
    "path": "jest.config.js",
    "chars": 6305,
    "preview": "// For a detailed explanation regarding each configuration property, visit:\n// https://jestjs.io/docs/en/configuration.h"
  },
  {
    "path": "package.json",
    "chars": 1113,
    "preview": "{\n  \"name\": \"@twilio-labs/actions-sms\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Send an SMS through GitHub Actions\",\n  \""
  },
  {
    "path": "src/main.ts",
    "chars": 1091,
    "preview": "const core = require('@actions/core');\nconst twilio = require('twilio');\n\nasync function run() {\n  const from = core.get"
  },
  {
    "path": "tsconfig.json",
    "chars": 468,
    "preview": "{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"outDir\": \"./dist\",\n    \"target\": \"es2018\",\n    \"strict\": true,\n "
  }
]

About this extraction

This page contains the full source code of the twilio-labs/actions-sms GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 13 files (18.0 KB), approximately 4.9k tokens, and a symbol index with 4 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!