├── .eslintignore ├── .nvmrc ├── dist ├── package.json └── licenses.txt ├── .husky ├── commit-msg └── pre-commit ├── .commitlintrc ├── .prettierrc ├── .editorconfig ├── src ├── index.js ├── action.js └── action.test.js ├── .gitignore ├── .github ├── dependabot.yml └── workflows │ ├── notify-release.yml │ ├── check-linked-issues.yml │ ├── ci.yml │ └── release.yml ├── babel.config.cjs ├── .eslintrc ├── jest.config.cjs ├── package.json ├── action.yml └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | dist -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | lts/* 2 | -------------------------------------------------------------------------------- /dist/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | npx --no -- commitlint --edit $1 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npx lint-staged 2 | npm run build && git add dist 3 | -------------------------------------------------------------------------------- /.commitlintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@commitlint/config-conventional" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "arrowParens": "avoid", 5 | "trailingComma": "none" 6 | } 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | end_of_line = lf 3 | insert_final_newline = true 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | 3 | import { run } from './action.js' 4 | 5 | run().catch(error => core.setFailed(error)) 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .eslintcache 3 | 4 | # JetBrains IDEs 5 | .idea 6 | # Visual Studio Code 7 | .vscode 8 | # Jest test coverage output 9 | coverage 10 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: 'npm' 4 | directory: '/' 5 | schedule: 6 | interval: 'daily' 7 | - package-ecosystem: 'github-actions' 8 | directory: '/' 9 | schedule: 10 | interval: 'daily' 11 | -------------------------------------------------------------------------------- /babel.config.cjs: -------------------------------------------------------------------------------- 1 | // Babel is used here only for transpiling ESM to CJS for Jest 2 | 3 | module.exports = { 4 | presets: [ 5 | [ 6 | "@babel/preset-env", 7 | { 8 | targets: { 9 | node: "current", 10 | }, 11 | }, 12 | ], 13 | ], 14 | }; -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:prettier/recommended", 5 | "plugin:jest/recommended" 6 | ], 7 | "env": { 8 | "node": true, 9 | "es2021": true, 10 | "jest/globals": true 11 | }, 12 | "parserOptions": { 13 | "ecmaVersion": 2021, 14 | "sourceType": "module" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jest.config.cjs: -------------------------------------------------------------------------------- 1 | // See all available options at https://jestjs.io/docs/configuration 2 | 3 | module.exports = { 4 | collectCoverage: true, 5 | coverageDirectory: "coverage", 6 | coveragePathIgnorePatterns: ["/node_modules/", "/__tests__/", "coverage"], 7 | testEnvironment: "node", 8 | moduleDirectories: ["node_modules", "src"], 9 | verbose: true, 10 | }; -------------------------------------------------------------------------------- /.github/workflows/notify-release.yml: -------------------------------------------------------------------------------- 1 | name: Notify release 2 | 'on': 3 | workflow_dispatch: 4 | release: 5 | types: 6 | - published 7 | issues: 8 | types: 9 | - closed 10 | schedule: 11 | - cron: 30 8 * * * 12 | jobs: 13 | setup: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | issues: write 17 | contents: read 18 | steps: 19 | - uses: nearform-actions/github-action-notify-release@v1 20 | -------------------------------------------------------------------------------- /.github/workflows/check-linked-issues.yml: -------------------------------------------------------------------------------- 1 | name: Check linked issues 2 | 'on': 3 | pull_request_target: 4 | types: 5 | - opened 6 | - edited 7 | - reopened 8 | - synchronize 9 | jobs: 10 | check_pull_requests: 11 | runs-on: ubuntu-latest 12 | name: Check linked issues 13 | permissions: 14 | issues: read 15 | pull-requests: write 16 | steps: 17 | - uses: nearform-actions/github-action-check-linked-issues@v1 18 | id: check-linked-issues 19 | with: 20 | github-token: ${{ secrets.GITHUB_TOKEN }} 21 | exclude-branches: release/**, dependabot/** 22 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | test: 11 | name: Lint and test 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v6 15 | - uses: actions/setup-node@v6 16 | with: 17 | node-version-file: '.nvmrc' 18 | - run: | 19 | npm ci 20 | npm run lint 21 | npm test 22 | 23 | automerge: 24 | name: Merge dependabot's PRs 25 | needs: test 26 | runs-on: ubuntu-latest 27 | permissions: 28 | pull-requests: write 29 | contents: write 30 | steps: 31 | - uses: fastify/github-action-merge-dependabot@v3 32 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Create a release 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | semver: 6 | description: The semver to use 7 | required: true 8 | default: patch 9 | type: choice 10 | options: 11 | - patch 12 | - minor 13 | - major 14 | pull_request: 15 | types: [closed] 16 | 17 | jobs: 18 | release: 19 | permissions: 20 | contents: write 21 | issues: write 22 | pull-requests: write 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v6 26 | - uses: actions/setup-node@v6 27 | with: 28 | node-version-file: .nvmrc 29 | - uses: nearform-actions/optic-release-automation-action@v4 30 | with: 31 | semver: ${{ github.event.inputs.semver }} 32 | sync-semver-tags: true 33 | commit-message: 'chore: release {version}' 34 | build-command: npm ci 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "github-action-notify-twitter", 3 | "version": "1.2.3", 4 | "description": "GitHub action that can send a custom message to a Twitter account", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "lint": "eslint .", 8 | "test": "jest", 9 | "prepare": "husky", 10 | "build": "ncc build src --license licenses.txt" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/nearform-actions/github-action-notify-twitter.git" 15 | }, 16 | "keywords": [], 17 | "author": "", 18 | "license": "ISC", 19 | "bugs": { 20 | "url": "https://github.com/nearform-actions/github-action-notify-twitter/issues" 21 | }, 22 | "homepage": "https://github.com/nearform-actions/github-action-notify-twitter#readme", 23 | "devDependencies": { 24 | "@babel/preset-env": "^7.28.5", 25 | "@commitlint/cli": "^20.2.0", 26 | "@commitlint/config-conventional": "^20.2.0", 27 | "@vercel/ncc": "^0.38.4", 28 | "eslint": "^8.57.0", 29 | "eslint-config-prettier": "^10.1.8", 30 | "eslint-plugin-jest": "^29.5.0", 31 | "eslint-plugin-prettier": "^4.2.5", 32 | "husky": "^9.1.7", 33 | "jest": "^30.2.0", 34 | "lint-staged": "^16.2.7", 35 | "prettier": "^2.8.8" 36 | }, 37 | "lint-staged": { 38 | "*.{js,jsx}": "eslint --cache --fix" 39 | }, 40 | "dependencies": { 41 | "@actions/core": "^2.0.1", 42 | "@actions/github": "^6.0.1", 43 | "actions-toolkit": "github:nearform/actions-toolkit", 44 | "twitter-api-v2": "^1.28.0" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | # See the syntax docs at 2 | # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions 3 | 4 | name: github-action-notify-twitter 5 | description: GitHub action that can send a custom message to a Twitter account 6 | 7 | inputs: 8 | message: 9 | description: > 10 | Message to post to Twitter. 11 | required: true 12 | twitter-app-key: 13 | description: > 14 | Consumer API key, available in the "Keys and tokens" 15 | section of your application in the Twitter Developer site. 16 | required: true 17 | twitter-app-secret: 18 | description: > 19 | Consumer API secret key, available in the "Keys and tokens" 20 | section of your application in the Twitter Developer site. 21 | required: true 22 | twitter-access-token: 23 | description: > 24 | Application access token, available in the "Keys and tokens" 25 | section of your application in the Twitter Developer site. 26 | required: true 27 | twitter-access-token-secret: 28 | description: > 29 | Application access token secret, available in the "Keys and tokens" 30 | section of your application in the Twitter Developer site. 31 | required: true 32 | media: 33 | description: > 34 | A list of paths for media objects (single photo, video or animated GIF) to use in the post 35 | required: false 36 | media-alt-text: 37 | description: > 38 | A list of image alternative text (alt text) that describe the meaning and the context of the image 39 | required: false 40 | 41 | runs: 42 | using: 'node20' 43 | main: 'dist/index.js' 44 | 45 | branding: 46 | icon: 'x' 47 | color: 'gray-dark' 48 | -------------------------------------------------------------------------------- /src/action.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const core = require('@actions/core') 3 | const { TwitterApi } = require('twitter-api-v2') 4 | const toolkit = require('actions-toolkit') 5 | 6 | export async function run() { 7 | toolkit.logActionRefWarning() 8 | toolkit.logRepoWarning() 9 | 10 | core.info(` 11 | *** ACTION RUN - START *** 12 | `) 13 | const MAX_MESSAGE_LENGTH = 280 14 | const message = core.getInput('message', { required: true }) 15 | const appKey = core.getInput('twitter-app-key', { required: true }) 16 | const appSecret = core.getInput('twitter-app-secret', { required: true }) 17 | const accessToken = core.getInput('twitter-access-token', { required: true }) 18 | const accessSecret = core.getInput('twitter-access-token-secret', { 19 | required: true 20 | }) 21 | const media = core 22 | .getInput('media', { required: false }) 23 | .split('\n') 24 | .map(input => input.trim()) 25 | .filter(Boolean) 26 | const mediaAltText = core 27 | .getInput('media-alt-text', { 28 | required: false, 29 | trimWhitespace: false 30 | }) 31 | .split('\n') 32 | .map(input => input.trim()) 33 | 34 | if (message.length > MAX_MESSAGE_LENGTH) { 35 | core.setFailed( 36 | 'The message is too long. The message may contain up to 280 characters.' 37 | ) 38 | core.info(` 39 | *** ACTION RUN - END *** 40 | `) 41 | return 42 | } 43 | 44 | const client = new TwitterApi({ 45 | appKey, 46 | appSecret, 47 | accessToken, 48 | accessSecret 49 | }) 50 | 51 | const rwClient = client.readWrite 52 | const tweetOpts = {} 53 | 54 | try { 55 | if (media.length) { 56 | const media_ids = await uploadMedia(rwClient, media, mediaAltText) 57 | tweetOpts.media = { media_ids } 58 | } 59 | } catch (err) { 60 | core.setFailed( 61 | `Action failed with error. ${err} ${ 62 | JSON.stringify(err.data) ?? '' 63 | }`.trim() 64 | ) 65 | core.info(` 66 | *** ACTION RUN - END *** 67 | `) 68 | return 69 | } 70 | 71 | try { 72 | core.info(`Twitter message: ${message}`) 73 | await rwClient.v2.tweet(message, tweetOpts) 74 | } catch (err) { 75 | core.setFailed( 76 | `Action failed with error. ${err} ${ 77 | JSON.stringify(err.data) ?? '' 78 | }`.trim() 79 | ) 80 | } finally { 81 | core.info(` 82 | *** ACTION RUN - END *** 83 | `) 84 | } 85 | } 86 | 87 | export async function uploadMedia(client, media, mediaAltText) { 88 | core.info(`Twitter upload media: ${media.join('; ')}`) 89 | 90 | const mediaIds = await Promise.all( 91 | media.map(media => client.v1.uploadMedia(media)) 92 | ) 93 | core.info(`Twitter upload completed - mediaIds: ${mediaIds.join('; ')}`) 94 | 95 | if (mediaAltText?.length) { 96 | try { 97 | await Promise.all( 98 | mediaIds.map((mediaId, index) => { 99 | core.info( 100 | `Twitter createMediaMetadata - mediaId: 101 | ${mediaId} ; alt-text: ${mediaAltText[index]}` 102 | ) 103 | if (!mediaAltText?.[index]?.trim()) return Promise.resolve() 104 | return client.v1.createMediaMetadata(mediaId, { 105 | alt_text: { text: mediaAltText[index] } 106 | }) 107 | }) 108 | ) 109 | } catch (err) { 110 | core.warning( 111 | `Twitter createMediaMetadata - Failed. ${err} ${ 112 | JSON.stringify(err.data) ?? '' 113 | }`.trim() 114 | ) 115 | } 116 | } 117 | return mediaIds 118 | } 119 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Github Action to send Twitter notifications 2 | 3 | [![CI](https://github.com/nearform-actions/github-action-notify-twitter/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/nearform-actions/github-action-notify-twitter/actions/workflows/ci.yml) 4 | 5 | GitHub action that can send a custom message to a Twitter account. 6 | 7 | ## Usage 8 | 9 | Configure this action in your workflows providing the following inputs described below. The Twitter tokens can be obtained from the Twitter Developer Portal under your project. 10 | 11 | ## Inputs 12 | 13 | | input | required | description | 14 | |-------------------------------|----------|-------------| 15 | | `message` | yes | Message to post to Twitter. | 16 | | `twitter-app-key` | yes | Consumer API key, available in the "Keys and tokens" section of your application in the Twitter Developer site. | 17 | | `twitter-app-secret` | yes | Consumer API secret key, available in the "Keys and tokens" section of your application in the Twitter Developer site. | 18 | | `twitter-access-token` | yes | Application access token, available in the "Keys and tokens" section of your application in the Twitter Developer site. | 19 | | `twitter-access-token-secret` | yes | Application access token secret, available in the "Keys and tokens" section of your application in the Twitter Developer site. | 20 | | `media` | no | A list of paths for media objects (image, video or animated GIF) to use in the post. | 21 | | `media-alt-text` | no | A list of image alternative text (alt text) that describe the meaning and the context of the image. | 22 | 23 | 24 | ## Example usage 25 | 26 | The example below runs when the release is published and also allows to trigger the action manually. 27 | 28 | ```yml 29 | name: Notify twitter 30 | 31 | on: 32 | workflow_dispatch: 33 | release: 34 | types: [published] 35 | 36 | jobs: 37 | setup: 38 | runs-on: ubuntu-latest 39 | steps: 40 | - uses: nearform-actions/github-action-notify-twitter@master 41 | with: 42 | message: | 43 | ${{ github.event.repository.name }} ${{ github.event.release.tag_name }} has been released. Check out the release notes: ${{ github.event.release.html_url }} 44 | twitter-app-key: ${{ secrets.TWITTER_APP_KEY }} 45 | twitter-app-secret: ${{ secrets.TWITTER_APP_SECRET }} 46 | twitter-access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} 47 | twitter-access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} 48 | 49 | ``` 50 | 51 | You can add media (image, GIF or video) to your post using the `media` parameter. This refers to the path of an image within the repository. 52 | The Twitter API currently supports a maximum of four media elements. 53 | For images and GIFs, you can also add an alt text using the `media-alt-text` parameter. This parameter is also a list and maintains the structure of the `media` parameter. So if you want to add an alt text only to the second content you have to write it in the second position of the list leaving the previous ones empty. 54 | 55 | ```yml 56 | name: Notify twitter 57 | 58 | on: 59 | workflow_dispatch: 60 | release: 61 | types: [published] 62 | 63 | jobs: 64 | setup: 65 | runs-on: ubuntu-latest 66 | steps: 67 | - uses: nearform-actions/github-action-notify-twitter@master 68 | with: 69 | message: | 70 | ${{ github.event.repository.name }} ${{ github.event.release.tag_name }} has been released. Check out the release notes: ${{ github.event.release.html_url }} 71 | twitter-app-key: ${{ secrets.TWITTER_APP_KEY }} 72 | twitter-app-secret: ${{ secrets.TWITTER_APP_SECRET }} 73 | twitter-access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} 74 | twitter-access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} 75 | media: | 76 | ./video.mp4 77 | ./twitter-x.png 78 | ./twitter-x.png 79 | media-alt-text: | 80 | 81 | alt icon 1 82 | alt icon 2 83 | ``` 84 | 85 | [![banner](https://raw.githubusercontent.com/nearform/.github/refs/heads/master/assets/os-banner-green.svg)](https://www.nearform.com/contact/?utm_source=open-source&utm_medium=banner&utm_campaign=os-project-pages) 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/action.test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const { getInput, setFailed, info, warning } = require('@actions/core') 3 | const { TwitterApi } = require('twitter-api-v2') 4 | const { run, uploadMedia } = require('./action') 5 | 6 | const ACTION_INPUTS = { 7 | message: 'Hello twitter', 8 | 'twitter-app-key': 'app-key', 9 | 'twitter-app-secret': 'app-secret', 10 | 'twitter-access-token': 'access-token', 11 | 'twitter-access-token-secret': 'access-token-secret' 12 | } 13 | 14 | jest.mock('@actions/core') 15 | jest.mock('twitter-api-v2') 16 | jest.mock('actions-toolkit') 17 | 18 | describe('action', () => { 19 | beforeEach(() => { 20 | setFailed.mockImplementation(message => message) 21 | info.mockImplementation(message => message) 22 | warning.mockImplementation(message => message) 23 | }) 24 | 25 | afterEach(() => { 26 | jest.clearAllMocks() 27 | }) 28 | 29 | it('tweet was sent successfully', async () => { 30 | getInput.mockImplementation(inputName => ACTION_INPUTS[inputName] ?? '') 31 | TwitterApi.mockImplementation(() => { 32 | return { 33 | readWrite: { 34 | v2: { 35 | tweet: async message => message || null 36 | } 37 | } 38 | } 39 | }) 40 | 41 | await run() 42 | 43 | expect(setFailed).not.toHaveBeenCalled() 44 | }) 45 | 46 | it('sending tweet failed', async () => { 47 | getInput.mockImplementation(inputName => ACTION_INPUTS[inputName] ?? '') 48 | TwitterApi.mockImplementation(() => { 49 | return { 50 | readWrite: { 51 | v2: { 52 | tweet: async () => { 53 | throw Error('Something went wrong') 54 | } 55 | } 56 | } 57 | } 58 | }) 59 | 60 | await run() 61 | 62 | expect(setFailed).toHaveBeenCalledWith( 63 | 'Action failed with error. Error: Something went wrong' 64 | ) 65 | }) 66 | 67 | it('sending tweet failed with error data object', async () => { 68 | getInput.mockImplementation(inputName => ACTION_INPUTS[inputName] ?? '') 69 | TwitterApi.mockImplementation(() => { 70 | return { 71 | readWrite: { 72 | v2: { 73 | tweet: async () => { 74 | const error = new Error('API Error') 75 | error.data = { 76 | code: 429, 77 | message: 'Rate limit exceeded', 78 | details: { 79 | reset_time: '2023-01-01T00:00:00Z', 80 | limit: 300 81 | } 82 | } 83 | throw error 84 | } 85 | } 86 | } 87 | } 88 | }) 89 | 90 | await run() 91 | 92 | expect(setFailed).toHaveBeenCalledWith( 93 | 'Action failed with error. Error: API Error {"code":429,"message":"Rate limit exceeded","details":{"reset_time":"2023-01-01T00:00:00Z","limit":300}}' 94 | ) 95 | }) 96 | 97 | it('fail the action when message is more than 280 characters long', async () => { 98 | const MESSAGE_TOO_LONG_ACTION_INPUTS = { 99 | message: 100 | 'Donec quis ipsum a mi tempor venenatis tincidunt feugiat nisi. Donec ac arcu dictum, efficitur nisl vehicula, fringilla sem. Fusce sed interdum sapien, id placerat felis. Sed vel velit urna. Proin pretium mauris at mi fermentum tincidunt. Praesent laoreet mi lectus, nec fringilla velit blandit ut.', 101 | 'twitter-app-key': 'app-key', 102 | 'twitter-app-secret': 'app-secret', 103 | 'twitter-access-token': 'access-token', 104 | 'twitter-access-token-secret': 'access-token-secret' 105 | } 106 | getInput.mockImplementation( 107 | inputName => MESSAGE_TOO_LONG_ACTION_INPUTS[inputName] ?? '' 108 | ) 109 | TwitterApi.mockImplementation(() => { 110 | return { 111 | readWrite: { 112 | v2: { 113 | tweet: async message => message || null 114 | } 115 | } 116 | } 117 | }) 118 | 119 | await run() 120 | 121 | expect(setFailed).toHaveBeenCalledWith( 122 | 'The message is too long. The message may contain up to 280 characters.' 123 | ) 124 | }) 125 | 126 | it('tweet with media and alt text was sent successfully', async () => { 127 | const MEDIA_ACTION_INPUTS = { 128 | ...ACTION_INPUTS, 129 | media: `./image.png, 130 | ./image.png`, 131 | 'media-alt-text': `alt text1 132 | alt text2` 133 | } 134 | getInput.mockImplementation( 135 | inputName => MEDIA_ACTION_INPUTS[inputName] ?? '' 136 | ) 137 | TwitterApi.mockImplementation(() => { 138 | return { 139 | readWrite: { 140 | v2: { 141 | tweet: async message => message || null 142 | }, 143 | v1: { 144 | uploadMedia: async () => 'id1', 145 | createMediaMetadata: async () => null 146 | } 147 | } 148 | } 149 | }) 150 | await run() 151 | 152 | expect(setFailed).not.toHaveBeenCalled() 153 | }) 154 | 155 | it('tweet with media (without alt text) was sent successfully', async () => { 156 | const MEDIA_ACTION_INPUTS = { 157 | ...ACTION_INPUTS, 158 | media: './image.png' 159 | } 160 | getInput.mockImplementation( 161 | inputName => MEDIA_ACTION_INPUTS[inputName] ?? '' 162 | ) 163 | TwitterApi.mockImplementation(() => { 164 | return { 165 | readWrite: { 166 | v2: { 167 | tweet: async message => message || null 168 | }, 169 | v1: { 170 | uploadMedia: async () => 'id1', 171 | createMediaMetadata: async () => null 172 | } 173 | } 174 | } 175 | }) 176 | 177 | await run() 178 | 179 | expect(setFailed).not.toHaveBeenCalled() 180 | }) 181 | 182 | it('tweet with media and error on createMediaMetadata was sent successfully', async () => { 183 | const MEDIA_ACTION_INPUTS = { 184 | ...ACTION_INPUTS, 185 | media: './image.png', 186 | 'media-alt-text': 'alt text' 187 | } 188 | getInput.mockImplementation( 189 | inputName => MEDIA_ACTION_INPUTS[inputName] ?? '' 190 | ) 191 | TwitterApi.mockImplementation(() => { 192 | return { 193 | readWrite: { 194 | v2: { 195 | tweet: async message => message || null 196 | }, 197 | v1: { 198 | uploadMedia: async () => 'id1', 199 | createMediaMetadata: async () => { 200 | throw Error('Something went wrong, upload fail') 201 | } 202 | } 203 | } 204 | } 205 | }) 206 | 207 | await run() 208 | 209 | expect(setFailed).not.toHaveBeenCalled() 210 | expect(warning).toHaveBeenCalled() 211 | }) 212 | 213 | it('tweet with media and error on createMediaMetadata with error data object was sent successfully', async () => { 214 | const MEDIA_ACTION_INPUTS = { 215 | ...ACTION_INPUTS, 216 | media: './image.png', 217 | 'media-alt-text': 'alt text' 218 | } 219 | getInput.mockImplementation( 220 | inputName => MEDIA_ACTION_INPUTS[inputName] ?? '' 221 | ) 222 | TwitterApi.mockImplementation(() => { 223 | return { 224 | readWrite: { 225 | v2: { 226 | tweet: async message => message || null 227 | }, 228 | v1: { 229 | uploadMedia: async () => 'id1', 230 | createMediaMetadata: async () => { 231 | const error = new Error('Metadata creation failed') 232 | error.data = { 233 | error_code: 44, 234 | message: 'attachment_url parameter is invalid', 235 | request: '/1.1/media/metadata/create.json' 236 | } 237 | throw error 238 | } 239 | } 240 | } 241 | } 242 | }) 243 | 244 | await run() 245 | 246 | expect(setFailed).not.toHaveBeenCalled() 247 | expect(warning).toHaveBeenCalledWith( 248 | 'Twitter createMediaMetadata - Failed. Error: Metadata creation failed {"error_code":44,"message":"attachment_url parameter is invalid","request":"/1.1/media/metadata/create.json"}' 249 | ) 250 | }) 251 | 252 | it('sending tweet with media failed', async () => { 253 | const MEDIA_ACTION_INPUTS = { 254 | ...ACTION_INPUTS, 255 | media: './image.png', 256 | 'media-alt-text': 'alt text' 257 | } 258 | getInput.mockImplementation( 259 | inputName => MEDIA_ACTION_INPUTS[inputName] ?? '' 260 | ) 261 | TwitterApi.mockImplementation(() => { 262 | return { 263 | readWrite: { 264 | v2: { 265 | tweet: async () => { 266 | throw Error('Something went wrong') 267 | } 268 | }, 269 | v1: { 270 | uploadMedia: async () => { 271 | throw Error('Something went wrong, upload fail') 272 | }, 273 | createMediaMetadata: async () => null 274 | } 275 | } 276 | } 277 | }) 278 | 279 | await run() 280 | 281 | expect(setFailed).toHaveBeenCalledWith( 282 | 'Action failed with error. Error: Something went wrong, upload fail' 283 | ) 284 | }) 285 | 286 | it('sending tweet with media failed with error data object', async () => { 287 | const MEDIA_ACTION_INPUTS = { 288 | ...ACTION_INPUTS, 289 | media: './image.png', 290 | 'media-alt-text': 'alt text' 291 | } 292 | getInput.mockImplementation( 293 | inputName => MEDIA_ACTION_INPUTS[inputName] ?? '' 294 | ) 295 | TwitterApi.mockImplementation(() => { 296 | return { 297 | readWrite: { 298 | v2: { 299 | tweet: async () => { 300 | throw Error('Something went wrong') 301 | } 302 | }, 303 | v1: { 304 | uploadMedia: async () => { 305 | const error = new Error('Upload failed') 306 | error.data = { 307 | error_code: 324, 308 | message: 'The validation of media ids failed', 309 | request: '/1.1/media/upload.json' 310 | } 311 | throw error 312 | }, 313 | createMediaMetadata: async () => null 314 | } 315 | } 316 | } 317 | }) 318 | 319 | await run() 320 | 321 | expect(setFailed).toHaveBeenCalledWith( 322 | 'Action failed with error. Error: Upload failed {"error_code":324,"message":"The validation of media ids failed","request":"/1.1/media/upload.json"}' 323 | ) 324 | }) 325 | 326 | it('tweet with multiple media and multiple alt text was sent successfully (different number of element)', async () => { 327 | const MEDIA_ACTION_INPUTS = { 328 | ...ACTION_INPUTS, 329 | media: `./image.png, 330 | ./image.png`, 331 | 'media-alt-text': `alt text` 332 | } 333 | getInput.mockImplementation( 334 | inputName => MEDIA_ACTION_INPUTS[inputName] ?? '' 335 | ) 336 | TwitterApi.mockImplementation(() => { 337 | return { 338 | readWrite: { 339 | v2: { 340 | tweet: async message => message || null 341 | }, 342 | v1: { 343 | uploadMedia: async () => 'id1', 344 | createMediaMetadata: async () => null 345 | } 346 | } 347 | } 348 | }) 349 | await run() 350 | 351 | expect(setFailed).not.toHaveBeenCalled() 352 | }) 353 | }) 354 | 355 | describe('uploadMedia', () => { 356 | beforeEach(() => { 357 | info.mockImplementation(message => message) 358 | warning.mockImplementation(message => message) 359 | }) 360 | 361 | afterEach(() => { 362 | jest.clearAllMocks() 363 | }) 364 | 365 | it('upload media without alt text', async () => { 366 | const client = { 367 | v1: { 368 | uploadMedia: jest.fn(), 369 | createMediaMetadata: jest.fn() 370 | } 371 | } 372 | const media = ['file1.png', 'file2.png'] 373 | 374 | const mediaIds = await uploadMedia(client, media, null) 375 | expect(client.v1.uploadMedia).toHaveBeenCalledTimes(media.length) 376 | expect(client.v1.createMediaMetadata).toHaveBeenCalledTimes(0) 377 | expect(mediaIds).toHaveLength(media.length) 378 | }) 379 | 380 | it('upload media with alt text', async () => { 381 | const client = { 382 | v1: { 383 | uploadMedia: jest.fn(), 384 | createMediaMetadata: jest.fn() 385 | } 386 | } 387 | 388 | const media = ['file1.png', 'file2.png'] 389 | const alt_text = ['alt_text1'] 390 | 391 | const mediaIds = await uploadMedia(client, media, alt_text) 392 | expect(client.v1.uploadMedia).toHaveBeenCalledTimes(media.length) 393 | expect(client.v1.createMediaMetadata).toHaveBeenCalledTimes(alt_text.length) 394 | expect(mediaIds).toHaveLength(media.length) 395 | }) 396 | }) 397 | -------------------------------------------------------------------------------- /dist/licenses.txt: -------------------------------------------------------------------------------- 1 | @actions/core 2 | MIT 3 | The MIT License (MIT) 4 | 5 | Copyright 2019 GitHub 6 | 7 | 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: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | 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. 12 | 13 | @actions/exec 14 | MIT 15 | The MIT License (MIT) 16 | 17 | Copyright 2019 GitHub 18 | 19 | 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: 20 | 21 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 22 | 23 | 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. 24 | 25 | @actions/http-client 26 | MIT 27 | Actions Http Client for Node.js 28 | 29 | Copyright (c) GitHub, Inc. 30 | 31 | All rights reserved. 32 | 33 | MIT License 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 36 | associated documentation files (the "Software"), to deal in the Software without restriction, 37 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 38 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 39 | subject to the following conditions: 40 | 41 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 44 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 45 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 46 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 47 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 48 | 49 | 50 | @actions/io 51 | MIT 52 | The MIT License (MIT) 53 | 54 | Copyright 2019 GitHub 55 | 56 | 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: 57 | 58 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 59 | 60 | 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. 61 | 62 | @fastify/busboy 63 | MIT 64 | Copyright Brian White. All rights reserved. 65 | 66 | Permission is hereby granted, free of charge, to any person obtaining a copy 67 | of this software and associated documentation files (the "Software"), to 68 | deal in the Software without restriction, including without limitation the 69 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 70 | sell copies of the Software, and to permit persons to whom the Software is 71 | furnished to do so, subject to the following conditions: 72 | 73 | The above copyright notice and this permission notice shall be included in 74 | all copies or substantial portions of the Software. 75 | 76 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 77 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 78 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 79 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 80 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 81 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 82 | IN THE SOFTWARE. 83 | 84 | actions-toolkit 85 | ISC 86 | MIT License 87 | 88 | Copyright (c) 2022 NearForm 89 | 90 | Permission is hereby granted, free of charge, to any person obtaining a copy 91 | of this software and associated documentation files (the "Software"), to deal 92 | in the Software without restriction, including without limitation the rights 93 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 94 | copies of the Software, and to permit persons to whom the Software is 95 | furnished to do so, subject to the following conditions: 96 | 97 | The above copyright notice and this permission notice shall be included in all 98 | copies or substantial portions of the Software. 99 | 100 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 101 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 102 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 103 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 104 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 105 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 106 | SOFTWARE. 107 | 108 | 109 | tunnel 110 | MIT 111 | The MIT License (MIT) 112 | 113 | Copyright (c) 2012 Koichi Kobayashi 114 | 115 | Permission is hereby granted, free of charge, to any person obtaining a copy 116 | of this software and associated documentation files (the "Software"), to deal 117 | in the Software without restriction, including without limitation the rights 118 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 119 | copies of the Software, and to permit persons to whom the Software is 120 | furnished to do so, subject to the following conditions: 121 | 122 | The above copyright notice and this permission notice shall be included in 123 | all copies or substantial portions of the Software. 124 | 125 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 126 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 127 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 128 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 129 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 130 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 131 | THE SOFTWARE. 132 | 133 | 134 | twitter-api-v2 135 | Apache-2.0 136 | Apache License 137 | Version 2.0, January 2004 138 | http://www.apache.org/licenses/ 139 | 140 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 141 | 142 | 1. Definitions. 143 | 144 | "License" shall mean the terms and conditions for use, reproduction, 145 | and distribution as defined by Sections 1 through 9 of this document. 146 | 147 | "Licensor" shall mean the copyright owner or entity authorized by 148 | the copyright owner that is granting the License. 149 | 150 | "Legal Entity" shall mean the union of the acting entity and all 151 | other entities that control, are controlled by, or are under common 152 | control with that entity. For the purposes of this definition, 153 | "control" means (i) the power, direct or indirect, to cause the 154 | direction or management of such entity, whether by contract or 155 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 156 | outstanding shares, or (iii) beneficial ownership of such entity. 157 | 158 | "You" (or "Your") shall mean an individual or Legal Entity 159 | exercising permissions granted by this License. 160 | 161 | "Source" form shall mean the preferred form for making modifications, 162 | including but not limited to software source code, documentation 163 | source, and configuration files. 164 | 165 | "Object" form shall mean any form resulting from mechanical 166 | transformation or translation of a Source form, including but 167 | not limited to compiled object code, generated documentation, 168 | and conversions to other media types. 169 | 170 | "Work" shall mean the work of authorship, whether in Source or 171 | Object form, made available under the License, as indicated by a 172 | copyright notice that is included in or attached to the work 173 | (an example is provided in the Appendix below). 174 | 175 | "Derivative Works" shall mean any work, whether in Source or Object 176 | form, that is based on (or derived from) the Work and for which the 177 | editorial revisions, annotations, elaborations, or other modifications 178 | represent, as a whole, an original work of authorship. For the purposes 179 | of this License, Derivative Works shall not include works that remain 180 | separable from, or merely link (or bind by name) to the interfaces of, 181 | the Work and Derivative Works thereof. 182 | 183 | "Contribution" shall mean any work of authorship, including 184 | the original version of the Work and any modifications or additions 185 | to that Work or Derivative Works thereof, that is intentionally 186 | submitted to Licensor for inclusion in the Work by the copyright owner 187 | or by an individual or Legal Entity authorized to submit on behalf of 188 | the copyright owner. For the purposes of this definition, "submitted" 189 | means any form of electronic, verbal, or written communication sent 190 | to the Licensor or its representatives, including but not limited to 191 | communication on electronic mailing lists, source code control systems, 192 | and issue tracking systems that are managed by, or on behalf of, the 193 | Licensor for the purpose of discussing and improving the Work, but 194 | excluding communication that is conspicuously marked or otherwise 195 | designated in writing by the copyright owner as "Not a Contribution." 196 | 197 | "Contributor" shall mean Licensor and any individual or Legal Entity 198 | on behalf of whom a Contribution has been received by Licensor and 199 | subsequently incorporated within the Work. 200 | 201 | 2. Grant of Copyright License. Subject to the terms and conditions of 202 | this License, each Contributor hereby grants to You a perpetual, 203 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 204 | copyright license to reproduce, prepare Derivative Works of, 205 | publicly display, publicly perform, sublicense, and distribute the 206 | Work and such Derivative Works in Source or Object form. 207 | 208 | 3. Grant of Patent License. Subject to the terms and conditions of 209 | this License, each Contributor hereby grants to You a perpetual, 210 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 211 | (except as stated in this section) patent license to make, have made, 212 | use, offer to sell, sell, import, and otherwise transfer the Work, 213 | where such license applies only to those patent claims licensable 214 | by such Contributor that are necessarily infringed by their 215 | Contribution(s) alone or by combination of their Contribution(s) 216 | with the Work to which such Contribution(s) was submitted. If You 217 | institute patent litigation against any entity (including a 218 | cross-claim or counterclaim in a lawsuit) alleging that the Work 219 | or a Contribution incorporated within the Work constitutes direct 220 | or contributory patent infringement, then any patent licenses 221 | granted to You under this License for that Work shall terminate 222 | as of the date such litigation is filed. 223 | 224 | 4. Redistribution. You may reproduce and distribute copies of the 225 | Work or Derivative Works thereof in any medium, with or without 226 | modifications, and in Source or Object form, provided that You 227 | meet the following conditions: 228 | 229 | (a) You must give any other recipients of the Work or 230 | Derivative Works a copy of this License; and 231 | 232 | (b) You must cause any modified files to carry prominent notices 233 | stating that You changed the files; and 234 | 235 | (c) You must retain, in the Source form of any Derivative Works 236 | that You distribute, all copyright, patent, trademark, and 237 | attribution notices from the Source form of the Work, 238 | excluding those notices that do not pertain to any part of 239 | the Derivative Works; and 240 | 241 | (d) If the Work includes a "NOTICE" text file as part of its 242 | distribution, then any Derivative Works that You distribute must 243 | include a readable copy of the attribution notices contained 244 | within such NOTICE file, excluding those notices that do not 245 | pertain to any part of the Derivative Works, in at least one 246 | of the following places: within a NOTICE text file distributed 247 | as part of the Derivative Works; within the Source form or 248 | documentation, if provided along with the Derivative Works; or, 249 | within a display generated by the Derivative Works, if and 250 | wherever such third-party notices normally appear. The contents 251 | of the NOTICE file are for informational purposes only and 252 | do not modify the License. You may add Your own attribution 253 | notices within Derivative Works that You distribute, alongside 254 | or as an addendum to the NOTICE text from the Work, provided 255 | that such additional attribution notices cannot be construed 256 | as modifying the License. 257 | 258 | You may add Your own copyright statement to Your modifications and 259 | may provide additional or different license terms and conditions 260 | for use, reproduction, or distribution of Your modifications, or 261 | for any such Derivative Works as a whole, provided Your use, 262 | reproduction, and distribution of the Work otherwise complies with 263 | the conditions stated in this License. 264 | 265 | 5. Submission of Contributions. Unless You explicitly state otherwise, 266 | any Contribution intentionally submitted for inclusion in the Work 267 | by You to the Licensor shall be under the terms and conditions of 268 | this License, without any additional terms or conditions. 269 | Notwithstanding the above, nothing herein shall supersede or modify 270 | the terms of any separate license agreement you may have executed 271 | with Licensor regarding such Contributions. 272 | 273 | 6. Trademarks. This License does not grant permission to use the trade 274 | names, trademarks, service marks, or product names of the Licensor, 275 | except as required for reasonable and customary use in describing the 276 | origin of the Work and reproducing the content of the NOTICE file. 277 | 278 | 7. Disclaimer of Warranty. Unless required by applicable law or 279 | agreed to in writing, Licensor provides the Work (and each 280 | Contributor provides its Contributions) on an "AS IS" BASIS, 281 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 282 | implied, including, without limitation, any warranties or conditions 283 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 284 | PARTICULAR PURPOSE. You are solely responsible for determining the 285 | appropriateness of using or redistributing the Work and assume any 286 | risks associated with Your exercise of permissions under this License. 287 | 288 | 8. Limitation of Liability. In no event and under no legal theory, 289 | whether in tort (including negligence), contract, or otherwise, 290 | unless required by applicable law (such as deliberate and grossly 291 | negligent acts) or agreed to in writing, shall any Contributor be 292 | liable to You for damages, including any direct, indirect, special, 293 | incidental, or consequential damages of any character arising as a 294 | result of this License or out of the use or inability to use the 295 | Work (including but not limited to damages for loss of goodwill, 296 | work stoppage, computer failure or malfunction, or any and all 297 | other commercial damages or losses), even if such Contributor 298 | has been advised of the possibility of such damages. 299 | 300 | 9. Accepting Warranty or Additional Liability. While redistributing 301 | the Work or Derivative Works thereof, You may choose to offer, 302 | and charge a fee for, acceptance of support, warranty, indemnity, 303 | or other liability obligations and/or rights consistent with this 304 | License. However, in accepting such obligations, You may act only 305 | on Your own behalf and on Your sole responsibility, not on behalf 306 | of any other Contributor, and only if You agree to indemnify, 307 | defend, and hold each Contributor harmless for any liability 308 | incurred by, or claims asserted against, such Contributor by reason 309 | of your accepting any such warranty or additional liability. 310 | 311 | END OF TERMS AND CONDITIONS 312 | 313 | APPENDIX: How to apply the Apache License to your work. 314 | 315 | To apply the Apache License to your work, attach the following 316 | boilerplate notice, with the fields enclosed by brackets "[]" 317 | replaced with your own identifying information. (Don't include 318 | the brackets!) The text should be enclosed in the appropriate 319 | comment syntax for the file format. We also recommend that a 320 | file or class name and description of purpose be included on the 321 | same "printed page" as the copyright notice for easier 322 | identification within third-party archives. 323 | 324 | Copyright [yyyy] [name of copyright owner] 325 | 326 | Licensed under the Apache License, Version 2.0 (the "License"); 327 | you may not use this file except in compliance with the License. 328 | You may obtain a copy of the License at 329 | 330 | http://www.apache.org/licenses/LICENSE-2.0 331 | 332 | Unless required by applicable law or agreed to in writing, software 333 | distributed under the License is distributed on an "AS IS" BASIS, 334 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 335 | See the License for the specific language governing permissions and 336 | limitations under the License. 337 | 338 | 339 | undici 340 | MIT 341 | MIT License 342 | 343 | Copyright (c) Matteo Collina and Undici contributors 344 | 345 | Permission is hereby granted, free of charge, to any person obtaining a copy 346 | of this software and associated documentation files (the "Software"), to deal 347 | in the Software without restriction, including without limitation the rights 348 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 349 | copies of the Software, and to permit persons to whom the Software is 350 | furnished to do so, subject to the following conditions: 351 | 352 | The above copyright notice and this permission notice shall be included in all 353 | copies or substantial portions of the Software. 354 | 355 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 356 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 357 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 358 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 359 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 360 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 361 | SOFTWARE. 362 | --------------------------------------------------------------------------------