{"id":13474521,"url":"https://github.com/peter-evans/sendgrid-action","last_synced_at":"2025-04-30T17:20:59.097Z","repository":{"id":36988608,"uuid":"194487246","full_name":"peter-evans/sendgrid-action","owner":"peter-evans","description":"A GitHub Action to send email with SendGrid","archived":false,"fork":false,"pushed_at":"2022-06-20T00:53:08.000Z","size":26,"stargazers_count":34,"open_issues_count":1,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T03:41:45.991Z","etag":null,"topics":["email","github-action","nodejs","sendgrid"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peter-evans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-30T07:18:58.000Z","updated_at":"2024-09-27T05:54:25.000Z","dependencies_parsed_at":"2023-01-11T17:21:05.286Z","dependency_job_id":null,"html_url":"https://github.com/peter-evans/sendgrid-action","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":"0.052631578947368474","last_synced_commit":"493713102fd4c444976e8c92726f08fb1578b887"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fsendgrid-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fsendgrid-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fsendgrid-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fsendgrid-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-evans","download_url":"https://codeload.github.com/peter-evans/sendgrid-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251749106,"owners_count":21637455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","github-action","nodejs","sendgrid"],"created_at":"2024-07-31T16:01:12.907Z","updated_at":"2025-04-30T17:20:59.076Z","avatar_url":"https://github.com/peter-evans.png","language":"Dockerfile","funding_links":[],"categories":["Community Resources","五、按场景分类的实用Action"],"sub_categories":["Notifications and Messages","6. 通知与告警"],"readme":"# SendGrid Action\n[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-SendGrid%20Action-blue.svg?colorA=24292e\u0026colorB=0366d6\u0026style=flat\u0026longCache=true\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAM6wAADOsB5dZE0gAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAERSURBVCiRhZG/SsMxFEZPfsVJ61jbxaF0cRQRcRJ9hlYn30IHN/+9iquDCOIsblIrOjqKgy5aKoJQj4O3EEtbPwhJbr6Te28CmdSKeqzeqr0YbfVIrTBKakvtOl5dtTkK+v4HfA9PEyBFCY9AGVgCBLaBp1jPAyfAJ/AAdIEG0dNAiyP7+K1qIfMdonZic6+WJoBJvQlvuwDqcXadUuqPA1NKAlexbRTAIMvMOCjTbMwl1LtI/6KWJ5Q6rT6Ht1MA58AX8Apcqqt5r2qhrgAXQC3CZ6i1+KMd9TRu3MvA3aH/fFPnBodb6oe6HM8+lYHrGdRXW8M9bMZtPXUji69lmf5Cmamq7quNLFZXD9Rq7v0Bpc1o/tp0fisAAAAASUVORK5CYII=)](https://github.com/marketplace/actions/sendgrid-action)\n\nA GitHub Action to send email with [SendGrid](https://sendgrid.com/).\n\nThe action executes a Node.js script allowing you to customise sending email with the [Node.js API Library](https://github.com/sendgrid/sendgrid-nodejs).\n\n## Usage\n\n```yml\n    - name: SendGrid\n      uses: peter-evans/sendgrid-action@v1\n      env:\n        SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}\n```\n\n#### Secrets\n\nSet your SendGrid API key as a secret with the name `SENDGRID_API_KEY`.\nIf you don't have one you can sign up and get 100 emails per day for free [here](https://sendgrid.com/free/).\n\n#### Optionally specifying the script file path\n\nThe action assumes there is a Node.js script located at `.github/sendgrid.js`.\nThis path can be overridden with an environment variable.\n\n```yml\n    - name: SendGrid\n      uses: peter-evans/sendgrid-action@v1\n      env:\n        SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}\n        SCRIPT_FILEPATH: ./some-path/email-sending-script.js\n```\n\n#### Example script files\n\nThe following examples are quite basic use cases. For more complicated use cases see the list of examples [here](https://github.com/sendgrid/sendgrid-nodejs/tree/main/docs/use-cases).\n\nSending a single email to a single recipient:\n```node\n#! /usr/bin/env node\n\nconst sgMail = require('@sendgrid/mail');\nsgMail.setApiKey(process.env.SENDGRID_API_KEY);\n\nconst msg = {\n    to: 'recipient@example.org',\n    from: 'sender@example.org',\n    subject: 'Hello world',\n    text: 'Hello plain world!',\n    html: '\u003cp\u003eHello HTML world!\u003c/p\u003e',\n};\n\nsgMail\n    .send(msg)\n    .then(() =\u003e console.log('Mail sent successfully'))\n    .catch(error =\u003e console.error(error.toString()));\n```\n\nSending an attachment:\n```node\n#! /usr/bin/env node\n\nconst sgMail = require('@sendgrid/mail');\nsgMail.setApiKey(process.env.SENDGRID_API_KEY);\n\nconst fs = require('fs'),\n    filename = 'hello-world.pdf',\n    fileType = 'application/pdf',\n    data = fs.readFileSync('attachments/' + filename);\n\nconst msg = {\n    to: 'recipient@example.org',\n    from: 'sender@example.org',\n    subject: 'Hello world',\n    text: 'Hello plain world!',\n    html: '\u003cp\u003eHello HTML world!\u003c/p\u003e',\n    attachments: [\n        {\n            content: data.toString('base64'),\n            filename: filename,\n            type: fileType,\n            disposition: 'attachment',\n        },\n    ],\n};\n\nsgMail\n    .send(msg)\n    .then(() =\u003e console.log('Mail sent successfully'))\n    .catch(error =\u003e console.error(error.toString()));\n```\n\n**Note**: Your script file *must* be executable otherwise it will cause a `permission denied` error. Make it executable with this command.\n\n```bash\nchmod +x email-sending-script.js\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-evans%2Fsendgrid-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-evans%2Fsendgrid-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-evans%2Fsendgrid-action/lists"}