mirror of
https://github.com/SethCohen/github-releases-to-discord
synced 2026-09-14 20:13:23 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de60879a86 | ||
|
|
82d906cc6f | ||
|
|
feb5a40237 | ||
|
|
9fe781fdc7 | ||
|
|
74ded4247d | ||
|
|
e1dc0826fe | ||
|
|
e768ce1023 | ||
|
|
6ac5abea42 | ||
|
|
6aa0dd988c | ||
|
|
1e7bdfd173 | ||
|
|
47869497ed | ||
|
|
9737dc9002 | ||
|
|
26399c645d | ||
|
|
07c2e1c3e6 | ||
|
|
f184bc59c7 | ||
|
|
3449e38629 | ||
|
|
93d02ce871 | ||
|
|
5dc41089e6 | ||
|
|
5fd64bf266 | ||
|
|
60a5c60e64 | ||
|
|
925765f099 | ||
|
|
37afa88c8c | ||
|
|
735cca9de3 | ||
|
|
5ca1453a69 | ||
|
|
305fe9299d | ||
|
|
613ba269d7 | ||
|
|
940a1bd2d2 | ||
|
|
7de2fd1c2a | ||
|
|
97a481333d | ||
|
|
b7c20771bd | ||
|
|
8ca9da2ca8 | ||
|
|
254bf79196 | ||
|
|
1ce3bed332 | ||
|
|
933f3cffcf | ||
|
|
24b80abb6f | ||
|
|
f228faeb5e | ||
|
|
ba06d83352 | ||
|
|
ce7fc4a3be | ||
|
|
c240910f89 | ||
|
|
a12acb913f | ||
|
|
c8889535c4 | ||
|
|
c811a53b57 | ||
|
|
e67e0f9064 | ||
|
|
d76d7aafe4 | ||
|
|
a809bb6f0e | ||
|
|
998060befe | ||
|
|
27e9acb517 | ||
|
|
d019e5acd9 | ||
|
|
9e0e0c94da | ||
|
|
6aea64bf70 | ||
|
|
234bc3b25f | ||
|
|
6df64644c1 |
@@ -1,18 +0,0 @@
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
name: github-release-to-discord
|
||||
jobs:
|
||||
github-release-to-discord:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Handle Release
|
||||
uses: ./ # Uses an action in the root directory
|
||||
id: release
|
||||
with:
|
||||
webhook_url: ${{ secrets.WEBHOOK_URL }}
|
||||
color: "2105893"
|
||||
username: "Release Changelog"
|
||||
avatar_url: "https://cdn.discordapp.com/avatars/487431320314576937/bd64361e4ba6313d561d54e78c9e7171.png"
|
||||
@@ -8,7 +8,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google-github-actions/release-please-action@v3
|
||||
id: release
|
||||
with:
|
||||
release-type: node
|
||||
package-name: release-please-action
|
||||
token: ${{ secrets.WORKFLOW_TOKEN }}
|
||||
token: ${{ secrets.WORKFLOW_TOKEN }}
|
||||
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"revert","section":"Reverts","hidden":false},{"type":"docs","section":"Documentation","hidden":false},{"type":"style","section":"Styles","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"refactor","section":"Code Refactoring","hidden":false}]'
|
||||
@@ -0,0 +1,25 @@
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
name: test-action
|
||||
jobs:
|
||||
github-releases-to-discord:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Github Releases To Discord
|
||||
uses: ./ # Uses an action in the root directory
|
||||
with:
|
||||
webhook_url: ${{ inputs.WEBHOOK_URL }}
|
||||
color: ${{ inputs.COLOR }}
|
||||
username: ${{ inputs.USERNAME }}
|
||||
avatar_url: ${{ inputs.AVATAR_URL }}
|
||||
custom_html_url: ${{ inputs.CUSTOM_HTML_URL }}
|
||||
content: ${{ inputs.CONTENT }}
|
||||
footer_title: ${{ inputs.FOOTER_TITLE }}
|
||||
footer_icon_url: ${{ inputs.FOOTER_ICON_URL }}
|
||||
footer_timestamp: ${{ inputs.FOOTER_TIMESTAMP }}
|
||||
max_description: ${{ inputs.MAX_DESCRIPTION }}
|
||||
reduce_headings: ${{ inputs.REDUCE_HEADINGS }}
|
||||
remove_github_reference_links: ${{ inputs.REMOVE_GITHUB_REFERENCE_LINKS }}
|
||||
@@ -0,0 +1,15 @@
|
||||
name: Update SemVer Tags
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- '**'
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
update_semver:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Update semver tags
|
||||
uses: haya14busa/action-update-semver@v1
|
||||
@@ -2,3 +2,8 @@
|
||||
*.iml
|
||||
out
|
||||
gen
|
||||
.env
|
||||
release.json
|
||||
repository.json
|
||||
user.json
|
||||
tests/sample-test-release-v2.json
|
||||
|
||||
+139
@@ -1,5 +1,144 @@
|
||||
# Changelog
|
||||
|
||||
## [1.18.0](https://github.com/SethCohen/github-releases-to-discord/compare/v1.17.0...v1.18.0) (2025-06-17)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **index.js:** enhance sendWebhook function to handle rate limits with retries for improved reliability when sending requests to Discord ([feb5a40](https://github.com/SethCohen/github-releases-to-discord/commit/feb5a402377bc3da9cb9ea788964ece4e56f48cd))
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
* remove unnecessary test file from .gitignore and add sample test release JSON for local testing ([82d906c](https://github.com/SethCohen/github-releases-to-discord/commit/82d906cc6f29adbe413b3f26b55deafc3f08ceee))
|
||||
* update README for clarity and conciseness, improve formatting, and add new sections for better user guidance ([82d906c](https://github.com/SethCohen/github-releases-to-discord/commit/82d906cc6f29adbe413b3f26b55deafc3f08ceee))
|
||||
|
||||
## [1.17.0](https://github.com/SethCohen/github-releases-to-discord/compare/v1.16.2...v1.17.0) (2025-06-17)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **workflow:** add GitHub Actions workflow to automatically update SemVer tags on tag push events ([e768ce1](https://github.com/SethCohen/github-releases-to-discord/commit/e768ce10237a6100cccd7e80b2e994e9a2609150))
|
||||
|
||||
## [1.16.2](https://github.com/SethCohen/github-releases-to-discord/compare/v1.16.1...v1.16.2) (2024-10-18)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* update README output example ([6aa0dd9](https://github.com/SethCohen/github-releases-to-discord/commit/6aa0dd988c547f3b3a73463bc6e69d944621c613))
|
||||
|
||||
## [1.16.1](https://github.com/SethCohen/github-releases-to-discord/compare/v1.16.0...v1.16.1) (2024-10-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* correct conversion of standalone PR, issue, and changelog URLs to markdown format ([4786949](https://github.com/SethCohen/github-releases-to-discord/commit/47869497ed80cf0d6188692d82d71dff7a55dffe)), closes [#38](https://github.com/SethCohen/github-releases-to-discord/issues/38)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* update README with details on markdown link conversion and other features ([9737dc9](https://github.com/SethCohen/github-releases-to-discord/commit/9737dc900274be227db48f8e23c715aa00b4af59))
|
||||
|
||||
## [1.16.0](https://github.com/SethCohen/github-releases-to-discord/compare/v1.15.3...v1.16.0) (2024-10-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add function to convert PR, issue, and changelog links to markdown format ([07c2e1c](https://github.com/SethCohen/github-releases-to-discord/commit/07c2e1c3e60591d601b5d4b5bd4fc90e599867f8)), closes [#32](https://github.com/SethCohen/github-releases-to-discord/issues/32)
|
||||
|
||||
## [1.15.3](https://github.com/SethCohen/github-releases-to-discord/compare/v1.15.2...v1.15.3) (2024-10-18)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* add contribution guidelines to README.md ([5fd64bf](https://github.com/SethCohen/github-releases-to-discord/commit/5fd64bf266cea87ab4952ef9a4c6aaf099f266bc))
|
||||
* update version reference in README.md ([93d02ce](https://github.com/SethCohen/github-releases-to-discord/commit/93d02ce8714c5f3e201f5b379422e978b837774b))
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
* update .gitignore ([3449e38](https://github.com/SethCohen/github-releases-to-discord/commit/3449e38629b0c40dde5af524e2fef220dab24ead))
|
||||
* update package-lock.json ([5dc4108](https://github.com/SethCohen/github-releases-to-discord/commit/5dc41089e63d18b5b191533c34cdddeab34a07e8))
|
||||
|
||||
## [1.15.2](https://github.com/SethCohen/github-releases-to-discord/compare/v1.15.1...v1.15.2) (2024-10-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* improve [@mention](https://github.com/mention) parsing for GitHub usernames ([#33](https://github.com/SethCohen/github-releases-to-discord/issues/33)) ([925765f](https://github.com/SethCohen/github-releases-to-discord/commit/925765f099dcdc3b12316eaa6dc3c17506734b51))
|
||||
|
||||
## [1.15.1](https://github.com/SethCohen/github-releases-to-discord/compare/v1.15.0...v1.15.1) (2024-10-04)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* updated README.md ([613ba26](https://github.com/SethCohen/github-releases-to-discord/commit/613ba269d7fe40e97040da19de58b0ae00b47aaf))
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
* added test envs to .gitignore ([735cca9](https://github.com/SethCohen/github-releases-to-discord/commit/735cca9de37b345e69b0c74ff761610eab6f1fd1))
|
||||
* updated test action ([305fe92](https://github.com/SethCohen/github-releases-to-discord/commit/305fe9299dddb3a514f2b1692773570862c34d46))
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* code cleanup ([5ca1453](https://github.com/SethCohen/github-releases-to-discord/commit/5ca1453a69f962930450a9f77d4e20cc37e4110f))
|
||||
|
||||
## [1.15.0](https://github.com/SethCohen/github-releases-to-discord/compare/v1.14.0...v1.15.0) (2023-12-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added clip description at last newline ([#25](https://github.com/SethCohen/github-releases-to-discord/issues/25)) ([97a4813](https://github.com/SethCohen/github-releases-to-discord/commit/97a481333d0b902f599b12f03b47c4a6cbfa5e52))
|
||||
|
||||
## [1.14.0](https://github.com/SethCohen/github-releases-to-discord/compare/v1.13.1...v1.14.0) (2023-12-11)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added additional description formatting ([#23](https://github.com/SethCohen/github-releases-to-discord/issues/23)) ([8ca9da2](https://github.com/SethCohen/github-releases-to-discord/commit/8ca9da2ca8e3435ee9b0d387355c0fae255c16b0))
|
||||
* added max_description option ([8ca9da2](https://github.com/SethCohen/github-releases-to-discord/commit/8ca9da2ca8e3435ee9b0d387355c0fae255c16b0))
|
||||
* added reduce_headings option ([8ca9da2](https://github.com/SethCohen/github-releases-to-discord/commit/8ca9da2ca8e3435ee9b0d387355c0fae255c16b0))
|
||||
* description trimming ([8ca9da2](https://github.com/SethCohen/github-releases-to-discord/commit/8ca9da2ca8e3435ee9b0d387355c0fae255c16b0))
|
||||
|
||||
|
||||
### Styles
|
||||
|
||||
* parse common Github URLs to more appropriate display ([8ca9da2](https://github.com/SethCohen/github-releases-to-discord/commit/8ca9da2ca8e3435ee9b0d387355c0fae255c16b0))
|
||||
* reduce consecutive whitespace/newlines into a minimum of 2 to allow separation in paragraphs ([8ca9da2](https://github.com/SethCohen/github-releases-to-discord/commit/8ca9da2ca8e3435ee9b0d387355c0fae255c16b0))
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
* update README.md ([254bf79](https://github.com/SethCohen/github-releases-to-discord/commit/254bf7919618aea9ce0a3db67901010a20426def))
|
||||
|
||||
## [1.13.1](https://github.com/SethCohen/github-releases-to-discord/compare/v1.13.0...v1.13.1) (2023-09-23)
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
* updated action info ([c240910](https://github.com/SethCohen/github-releases-to-discord/commit/c240910f8922fb8492346613f67a84811a0fdbac))
|
||||
* updated action info ([c888953](https://github.com/SethCohen/github-releases-to-discord/commit/c8889535c4a02efec3e8a6b26e1ee17fcd36ac7b))
|
||||
* updated dependencies ([24b80ab](https://github.com/SethCohen/github-releases-to-discord/commit/24b80abb6f9c71123456a908af5d3b92ccc755af))
|
||||
* updated README.md ([ba06d83](https://github.com/SethCohen/github-releases-to-discord/commit/ba06d833522e55d3453ee27bea9a7f3655378359))
|
||||
* updated README.md ([ce7fc4a](https://github.com/SethCohen/github-releases-to-discord/commit/ce7fc4a3be811af077c4f43dd005851d65204fb1))
|
||||
* updated release-please action ([933f3cf](https://github.com/SethCohen/github-releases-to-discord/commit/933f3cffcf2139fcd71dddbb8bc76bc7cfa09170))
|
||||
|
||||
## [1.13.0](https://github.com/SethCohen/github-release-to-discord/compare/v1.12.1...v1.13.0) (2022-08-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* created test action ([d76d7aa](https://github.com/SethCohen/github-release-to-discord/commit/d76d7aafe49eadfc8d388bef38a8d3fb0230041b))
|
||||
|
||||
## [1.12.1](https://github.com/SethCohen/github-release-to-discord/compare/v1.12.0...v1.12.1) (2022-08-24)
|
||||
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* release 1.12.1 ([6aea64b](https://github.com/SethCohen/github-release-to-discord/commit/6aea64bf70aca011417fed5000ff080269024a93))
|
||||
|
||||
## [1.12.0](https://github.com/SethCohen/github-release-to-discord/compare/v1.11.1...v1.12.0) (2022-08-24)
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,49 @@
|
||||
# GitHub Release To Discord Action
|
||||
# GitHub Releases to Discord Action
|
||||
|
||||
This action parses a GitHub release and posts it to a Discord channel via a Discord webhook.
|
||||
## Configuration
|
||||
| Variable | Required | Default | Description |
|
||||
|------------|----------|----------------------------------------------------------------------------------------------------------------|--------------------------------------------|
|
||||
| webhook_url | ✔ | | Discord's webhook url. Use GH repo secrets. |
|
||||
| color | ❌ | "2105893" | Decimal color value for embed. |
|
||||
| username | ❌ | "Release Changelog" | String username for webhook. |
|
||||
| avatar_url | ❌ | ["Profile Picture"](https://cdn.discordapp.com/avatars/487431320314576937/bd64361e4ba6313d561d54e78c9e7171.png) | String url to webhook avatar picture. |
|
||||
Easily notify your Discord community about new GitHub releases! This GitHub Action automatically sends a beautifully formatted Discord embed message with your release notes whenever you publish a release on GitHub.
|
||||
|
||||
**Main Benefits:**
|
||||
|
||||
## Output
|
||||

|
||||
- Instantly share release changelogs with your Discord server.
|
||||
- Highly customizable message appearance and content.
|
||||
- Simple setup—no coding required.
|
||||
- Supports advanced formatting and filtering for professional notifications.
|
||||
|
||||
## Example usage
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
- **Automatic Release Notifications:** Sends a Discord embed when a GitHub release is published.
|
||||
- **Clean Formatting:**
|
||||
- Removes carriage returns and HTML comments.
|
||||
- Optimizes whitespace and paragraph spacing.
|
||||
- **Mention & Link Handling:**
|
||||
- Converts `@mentions` to clickable GitHub profile links.
|
||||
- Converts PR, issue, and changelog URLs to Markdown links.
|
||||
- Optionally removes PR, commit, and issue links for cleaner messages.
|
||||
- **Heading Reduction:**
|
||||
- Optionally reduces heading sizes for compact display.
|
||||
- **Custom Embed Appearance:**
|
||||
- Set color, username, avatar, footer, and more.
|
||||
- **Length Management:**
|
||||
- Ensures messages fit Discord's embed limits, trimming and linking as needed.
|
||||
- **Error Handling:**
|
||||
- Clear errors for missing or invalid inputs.
|
||||
- **Easy Integration:**
|
||||
- Works with any public or private repository.
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Create a Discord Webhook
|
||||
|
||||
- Go to your Discord server settings → **Integrations** → **Webhooks**.
|
||||
- Click **Create Webhook** and copy the webhook URL.
|
||||
|
||||
### 2. Add the Action to Your Workflow
|
||||
|
||||
Create (or update) `.github/workflows/github-releases-to-discord.yml`:
|
||||
|
||||
```yaml
|
||||
on:
|
||||
@@ -21,17 +51,132 @@ on:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
github-release-to-discord:
|
||||
github-releases-to-discord:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Handle Release
|
||||
uses: ./ # Uses an action in the root directory
|
||||
id: release
|
||||
- name: GitHub Releases to Discord
|
||||
uses: SethCohen/github-releases-to-discord@v1
|
||||
with:
|
||||
webhook_url: ${{ secrets.WEBHOOK_URL }}
|
||||
color: "2105893"
|
||||
username: "Release Changelog"
|
||||
avatar_url: "https://cdn.discordapp.com/avatars/487431320314576937/bd64361e4ba6313d561d54e78c9e7171.png"
|
||||
```
|
||||
content: "||@everyone||"
|
||||
footer_title: "Changelog"
|
||||
reduce_headings: true
|
||||
```
|
||||
|
||||
### 3. Add Your Webhook URL as a Secret
|
||||
|
||||
- In your GitHub repo, go to **Settings → Secrets and variables → Actions**.
|
||||
- Add a new secret named `WEBHOOK_URL` and paste your Discord webhook URL.
|
||||
|
||||
---
|
||||
|
||||
## Configuration Options
|
||||
|
||||
| Input Name | Required | Default | Description |
|
||||
|-------------------------------|----------|-------------|--------------------------------------------------------------------|
|
||||
| `webhook_url` | ✔ | | Discord webhook URL (use a GitHub secret). |
|
||||
| `color` | ❌ | 2105893 | Embed color (decimal). |
|
||||
| `username` | ❌ | | Webhook username. |
|
||||
| `avatar_url` | ❌ | | Webhook avatar image URL. |
|
||||
| `custom_html_url` | ❌ | | Custom URL for the embed title (overrides GitHub release URL). |
|
||||
| `content` | ❌ | | Additional message content (e.g., `@everyone`). |
|
||||
| `footer_title` | ❌ | | Footer title. |
|
||||
| `footer_icon_url` | ❌ | | Footer icon image URL. |
|
||||
| `footer_timestamp` | ❌ | false | Show timestamp in footer (`true`/`false`). |
|
||||
| `max_description` | ❌ | 4096 | Max description length (Discord limit: 4096). |
|
||||
| `remove_github_reference_links`| ❌ | false | Remove PR, commit, and issue links from the description. |
|
||||
| `reduce_headings` | ❌ | false | Reduce heading sizes for compact display. |
|
||||
|
||||
---
|
||||
|
||||
## Example Output
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## Best Practices & Notes
|
||||
|
||||
- **Use Secrets for Webhook URLs:** Never commit your Discord webhook URL directly to your repository.
|
||||
- **Discord Embed Limits:**
|
||||
- Title: 256 characters max
|
||||
- Description: 4096 characters max
|
||||
- The action will trim and link if limits are exceeded.
|
||||
- **Release Body Formatting:**
|
||||
- Use Markdown in your release notes for best results.
|
||||
- **Private Repos:**
|
||||
- The action works for both public and private repositories.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting & FAQ
|
||||
|
||||
**Q: The action didn't post to Discord!**
|
||||
|
||||
- Check that your webhook URL is correct and not expired.
|
||||
- Ensure the `webhook_url` secret is set in your repository.
|
||||
- Review the Actions log for error messages.
|
||||
|
||||
**Q: My message is cut off.**
|
||||
|
||||
- Discord has strict embed limits. The action trims long messages and adds a link if needed.
|
||||
|
||||
**Q: How do I customize the embed?**
|
||||
|
||||
- Use the configuration options above to set color, username, avatar, footer, and more.
|
||||
|
||||
**Q: Can I mention everyone or specific roles?**
|
||||
|
||||
- Use the `content` input (e.g., `content: "@everyone"`).
|
||||
|
||||
---
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome contributions! To get started:
|
||||
|
||||
1. **Fork** this repository.
|
||||
2. **Clone** your fork and run `npm install`.
|
||||
3. **Create a test release payload:**
|
||||
- Copy `tests/sample-test-release.json` and edit as needed.
|
||||
4. **Create a `.env` file** in the root with your webhook and config (see below):
|
||||
|
||||
```env
|
||||
INPUT_WEBHOOK_URL=your_webhook_url
|
||||
INPUT_COLOR=2105893
|
||||
...
|
||||
```
|
||||
|
||||
5. **Test locally** with [`act`](https://github.com/nektos/act):
|
||||
|
||||
```bash
|
||||
act release -e tests/sample-test-release.json
|
||||
```
|
||||
|
||||
6. **Make your changes** and commit using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
||||
7. **Open a pull request** with a clear description of your changes.
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
[MIT License](LICENSE)
|
||||
|
||||
---
|
||||
|
||||
## Support & Feedback
|
||||
|
||||
- **Issues:** [Open an issue](https://github.com/SethCohen/github-releases-to-discord/issues) for bugs, questions, or feature requests.
|
||||
- **Pull Requests:** Contributions are welcome—see above!
|
||||
|
||||
---
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
- Inspired by the needs of open source maintainers and Discord communities.
|
||||
- Built and maintained by [SethCohen](https://github.com/SethCohen).
|
||||
|
||||
+29
-4
@@ -1,6 +1,6 @@
|
||||
name: Github Releases To Discord
|
||||
author: SethCohen
|
||||
description: Send automatic styled releases to Discord.
|
||||
description: Automatically send a stylized Discord webhook of a GitHub Release description to a specified Discord channel.
|
||||
inputs:
|
||||
webhook_url:
|
||||
description: Discord's webhook url. Use GH repo secrets.
|
||||
@@ -12,14 +12,39 @@ inputs:
|
||||
username:
|
||||
description: String username for webhook.
|
||||
required: false
|
||||
default: 'Release Changelog'
|
||||
avatar_url:
|
||||
description: String url to webhook avatar picture.
|
||||
required: false
|
||||
default: 'https://cdn.discordapp.com/avatars/487431320314576937/bd64361e4ba6313d561d54e78c9e7171.png'
|
||||
custom_html_url:
|
||||
description: If filled, replaces github's release url with your custom html url.
|
||||
required: false
|
||||
content:
|
||||
description: String content for webhook.
|
||||
required: false
|
||||
footer_title:
|
||||
description: Title for the footer.
|
||||
required: false
|
||||
footer_icon_url:
|
||||
description: Icon url for the footer.
|
||||
required: false
|
||||
footer_timestamp:
|
||||
description: Timestamp for the footer.
|
||||
required: false
|
||||
max_description:
|
||||
description: Max length for the description.
|
||||
required: false
|
||||
default: '4096'
|
||||
remove_github_reference_links:
|
||||
description: Remove any PR, commit, and issue links from the description.
|
||||
required: false
|
||||
default: 'false'
|
||||
reduce_headings:
|
||||
description: Converts H3 to bold, h2 to bold & underline.
|
||||
required: false
|
||||
default: 'false'
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'index.js'
|
||||
branding:
|
||||
icon: file-text
|
||||
color: gray-dark
|
||||
color: blue
|
||||
|
||||
@@ -2,64 +2,277 @@ import core from '@actions/core';
|
||||
import github from '@actions/github';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
async function getContext () {
|
||||
const payload = github.context.payload
|
||||
/**
|
||||
* Removes carriage return characters.
|
||||
* @param {string} text The input text.
|
||||
* @returns {string} The text without carriage return characters.
|
||||
*/
|
||||
const removeCarriageReturn = (text) => text.replace(/\r/g, '');
|
||||
|
||||
return {
|
||||
body: payload.release.body.length < 1500
|
||||
? payload.release.body
|
||||
: payload.release.body.substring(0, 1500) + ` ([...](${payload.release.html_url}))`,
|
||||
version: payload.release.tag_name,
|
||||
html_url: payload.release.html_url
|
||||
/**
|
||||
* Removes HTML comments.
|
||||
* @param {string} text The input text.
|
||||
* @returns {string} The text without HTML comments.
|
||||
*/
|
||||
const removeHTMLComments = (text) => text.replace(/<!--.*?-->/gs, '');
|
||||
|
||||
/**
|
||||
* Reduces redundant newlines and spaces.
|
||||
* Keeps a maximum of 2 newlines to provide spacing between paragraphs.
|
||||
* @param {string} text The input text.
|
||||
* @returns {string} The text with reduced newlines.
|
||||
*/
|
||||
const reduceNewlines = (text) => text.replace(/\n\s*\n/g, (ws) => {
|
||||
const nlCount = (ws.match(/\n/g) || []).length;
|
||||
return nlCount >= 2 ? '\n\n' : '\n';
|
||||
});
|
||||
|
||||
/**
|
||||
* Converts @mentions to GitHub profile links for valid GitHub usernames.
|
||||
* @param {string} text The input text.
|
||||
* @returns {string} The text with valid @mentions converted to links.
|
||||
*/
|
||||
const convertMentionsToLinks = (text) => text.replace(
|
||||
/(?<![/@\w])@((?!-)(?!.*?--)[a-zA-Z0-9](?:-?[a-zA-Z0-9]){0,37})(?![.\w/-])(?!.*\])/g,
|
||||
(match, name) => `[@${name}](https://github.com/${name})`
|
||||
);
|
||||
|
||||
/**
|
||||
* Removes any GitHub PR, commit, or issue links from the text, including markdown links.
|
||||
* @param {string} text The input text.
|
||||
* @returns {string} The text without GitHub PR and commit links.
|
||||
*/
|
||||
const removeGithubReferenceLinks = (text) => text
|
||||
// Remove markdown links to PRs, commits, and issues
|
||||
.replace(/\[[^\]]*\]\(https:\/\/github\.com\/[^(\s)]+\/pull\/\d+\)/g, '')
|
||||
.replace(/\[[^\]]*\]\(https:\/\/github\.com\/[^(\s)]+\/commit\/\w+\)/g, '')
|
||||
.replace(/\[[^\]]*\]\(https:\/\/github\.com\/[^(\s)]+\/issues\/\d+\)/g, '')
|
||||
// Remove bare PR, commit, and issue URLs
|
||||
.replace(/https:\/\/github\.com\/[^(\s)]+\/pull\/\d+/g, '')
|
||||
.replace(/https:\/\/github\.com\/[^(\s)]+\/commit\/\w+/g, '')
|
||||
.replace(/https:\/\/github\.com\/[^(\s)]+\/issues\/\d+/g, '')
|
||||
// Remove empty parentheses left behind
|
||||
.replace(/\(\s*\)/g, '');
|
||||
|
||||
/**
|
||||
* Reduces headings to a smaller format if 'reduce_headings' is enabled.
|
||||
* Converts H3 to bold+underline, H2 to bold.
|
||||
* @param {string} text The input text.
|
||||
* @returns {string} The text with reduced heading sizes.
|
||||
*/
|
||||
const reduceHeadings = (text) => text
|
||||
.replace(/^###\s+(.+)$/gm, '**__$1__**') // Convert H3 to bold + underline
|
||||
.replace(/^##\s+(.+)$/gm, '**$1**'); // Convert H2 to bold
|
||||
|
||||
/**
|
||||
* Converts PR, issue, and changelog links to markdown format, ignoring existing markdown links.
|
||||
* - PR links: `https://github.com/OWNER/REPO/pull/1` -> `[PR #1](https://github.com/OWNER/REPO/pull/1)`
|
||||
* - Issue links: `https://github.com/OWNER/REPO/issues/1` -> `[Issue #30](https://github.com/OWNER/REPO/issues/1)`
|
||||
* - Changelog links: `https://github.com/OWNER/REPO/compare/v1.0.0...v1.1.0` -> `[v1.0.0...v1.1.0](https://github.com/OWNER/REPO/compare/v1.0.0...v1.1.0)`
|
||||
* @param {string} text The input text.
|
||||
* @returns {string} The text with links converted to markdown format.
|
||||
*/
|
||||
const convertLinksToMarkdown = (text) => {
|
||||
// Extract existing markdown links and replace them with placeholders
|
||||
const markdownLinks = [];
|
||||
const textWithoutMarkdownLinks = text.replace(/\[.*?\]\(.*?\)/g, (link) => {
|
||||
markdownLinks.push(link);
|
||||
return `__MARKDOWN_LINK_PLACEHOLDER_${markdownLinks.length - 1}__`;
|
||||
});
|
||||
|
||||
// Convert standalone PR, issue, and changelog URLs to markdown format
|
||||
let processedText = textWithoutMarkdownLinks
|
||||
.replace(/https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/pull\/(\d+)/g, (match, owner, repo, prNumber) => `[PR #${prNumber}](${match})`)
|
||||
.replace(/https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/issues\/(\d+)/g, (match, owner, repo, issueNumber) => `[Issue #${issueNumber}](${match})`)
|
||||
.replace(/https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/compare\/([v\w.-]+)\.\.\.([v\w.-]+)/g, (match, owner, repo, fromVersion, toVersion) => `[${fromVersion}...${toVersion}](${match})`);
|
||||
|
||||
// Reinsert the original markdown links
|
||||
return processedText.replace(/__MARKDOWN_LINK_PLACEHOLDER_(\d+)__/g, (match, index) => markdownLinks[parseInt(index, 10)]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stylizes a markdown body into an appropriate embed message style.
|
||||
* @param {string} description The description to format.
|
||||
* @returns {string} The formatted description.
|
||||
*/
|
||||
const formatDescription = (description) => {
|
||||
let edit = removeCarriageReturn(description);
|
||||
edit = removeHTMLComments(edit);
|
||||
edit = reduceNewlines(edit);
|
||||
|
||||
if (core.getBooleanInput('remove_github_reference_links')) {
|
||||
edit = removeGithubReferenceLinks(edit);
|
||||
}
|
||||
}
|
||||
edit = convertMentionsToLinks(edit);
|
||||
edit = convertLinksToMarkdown(edit);
|
||||
edit = edit.trim();
|
||||
|
||||
async function run () {
|
||||
if (core.getBooleanInput('reduce_headings')) {
|
||||
edit = reduceHeadings(edit);
|
||||
}
|
||||
|
||||
return edit;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the max description length, defaulting to 4096 if not set or invalid.
|
||||
* @returns {number} The max description length.
|
||||
*/
|
||||
const getMaxDescription = () => {
|
||||
try {
|
||||
const webhookUrl = core.getInput('webhook_url')
|
||||
const color = core.getInput('color')
|
||||
const username = core.getInput('username')
|
||||
const avatarUrl = core.getInput('avatar_url')
|
||||
|
||||
if (!webhookUrl) {
|
||||
return core.setFailed('webhook_url not set. Please set it.')
|
||||
const max = core.getInput('max_description');
|
||||
if (max && !isNaN(max)) {
|
||||
return Math.min(parseInt(max, 10), 4096);
|
||||
}
|
||||
|
||||
const content = await getContext()
|
||||
|
||||
const description = content.body
|
||||
.replace(/### (.*?)\n/g,function (substring) {
|
||||
const newString = substring.slice(4).replace(/(\r\n|\n|\r)/gm, "")
|
||||
return `**__${newString}__**`
|
||||
})
|
||||
.replace(/## (.*?)\n/g,function (substring) {
|
||||
const newString = substring.slice(3).replace(/(\r\n|\n|\r)/gm, "")
|
||||
return `**${newString}**`
|
||||
})
|
||||
.replace(/\n\s*\n/g, '\n')
|
||||
|
||||
const embedMsg = {
|
||||
title: `Release ${content.version}`,
|
||||
url: content.html_url,
|
||||
color: color,
|
||||
description: description,
|
||||
}
|
||||
|
||||
const body = { username: username, avatar_url: avatarUrl, embeds: [embedMsg], }
|
||||
|
||||
const url = `${webhookUrl}?wait=true`
|
||||
|
||||
fetch(url, {
|
||||
method: 'post',
|
||||
body: JSON.stringify(body),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => core.info(JSON.stringify(data)))
|
||||
.catch(err => core.info(err))
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
} catch (err) {
|
||||
core.warning(`Invalid max_description: ${err}`);
|
||||
}
|
||||
}
|
||||
return 4096;
|
||||
};
|
||||
|
||||
run()
|
||||
/**
|
||||
* Get the context of the action, returning a GitHub Release payload.
|
||||
* @returns {object} The context with release details.
|
||||
*/
|
||||
const getContext = () => {
|
||||
const { release } = github.context.payload;
|
||||
return {
|
||||
body: release.body,
|
||||
name: release.name,
|
||||
html_url: release.html_url
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Limits the string to a maximum length, optionally adding a URL or clipping at a newline.
|
||||
* @param {string} str The string to limit.
|
||||
* @param {number} maxLength The maximum allowed length.
|
||||
* @param {string} [url] Optional URL for linking the truncated text.
|
||||
* @param {boolean} [clipAtLine=false] Whether to clip at the nearest newline.
|
||||
* @returns {string} The limited string.
|
||||
*/
|
||||
const limitString = (str, maxLength, url, clipAtLine = false) => {
|
||||
if (str.length <= maxLength) return str;
|
||||
|
||||
const replacement = url
|
||||
? `${clipAtLine ? '\n' : ''}([…](${url}))`
|
||||
: (clipAtLine ? '\n…' : '…');
|
||||
|
||||
maxLength -= replacement.length;
|
||||
str = str.substring(0, maxLength);
|
||||
|
||||
const lastNewline = str.search(new RegExp(`[^${clipAtLine ? '\n' : '\s'}]*$`));
|
||||
if (lastNewline > -1) {
|
||||
str = str.substring(0, lastNewline);
|
||||
}
|
||||
|
||||
return str + replacement;
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds the embed message for the Discord webhook.
|
||||
* @param {string} name The title or name of the release.
|
||||
* @param {string} html_url The URL of the release.
|
||||
* @param {string} description The formatted description of the release.
|
||||
* @returns {object} The embed message to send in the webhook.
|
||||
*/
|
||||
const buildEmbedMessage = (name, html_url, description) => {
|
||||
const embedMsg = {
|
||||
title: limitString(name, 256),
|
||||
url: html_url,
|
||||
color: core.getInput('color'),
|
||||
description: limitString(description, Math.min(getMaxDescription(), 6000 - name.length)),
|
||||
footer: {}
|
||||
};
|
||||
|
||||
if (core.getInput('custom_html_url')) {
|
||||
embedMsg.url = core.getInput('custom_html_url');
|
||||
}
|
||||
if (core.getInput('footer_title')) {
|
||||
embedMsg.footer.text = limitString(core.getInput('footer_title'), 2048);
|
||||
}
|
||||
if (core.getInput('footer_icon_url')) {
|
||||
embedMsg.footer.icon_url = core.getInput('footer_icon_url');
|
||||
}
|
||||
if (core.getInput('footer_timestamp') === 'true') {
|
||||
embedMsg.timestamp = new Date().toISOString();
|
||||
}
|
||||
|
||||
return embedMsg;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends the webhook request to Discord, handling rate limits (429) with retries.
|
||||
* @param {string} webhookUrl The URL of the Discord webhook.
|
||||
* @param {object} requestBody The payload to send in the webhook.
|
||||
* @param {number} [maxRetries=3] Maximum number of retries on rate limit.
|
||||
*/
|
||||
const sendWebhook = async (webhookUrl, requestBody, maxRetries = 3) => {
|
||||
let attempt = 0;
|
||||
while (attempt <= maxRetries) {
|
||||
try {
|
||||
const response = await fetch(`${webhookUrl}?wait=true`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(requestBody),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
if (response.status === 429) {
|
||||
// Rate limited, get retry-after
|
||||
const retryAfter = parseInt(response.headers.get('retry-after') || '1', 10);
|
||||
core.warning(`Rate limited by Discord. Retrying after ${retryAfter} seconds (attempt ${attempt + 1}/${maxRetries})`);
|
||||
await new Promise(res => setTimeout(res, retryAfter * 1000));
|
||||
attempt++;
|
||||
continue;
|
||||
}
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
core.setFailed(`Discord webhook error: ${JSON.stringify(data)}`);
|
||||
} else {
|
||||
core.info(JSON.stringify(data));
|
||||
}
|
||||
break;
|
||||
} catch (err) {
|
||||
core.setFailed(err.message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (attempt > maxRetries) {
|
||||
core.setFailed('Exceeded maximum Discord webhook retry attempts due to rate limiting.');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds the request body for the Discord webhook.
|
||||
* @param {object} embedMsg The embed message to include in the request body.
|
||||
* @returns {object} The request body for the webhook.
|
||||
*/
|
||||
const buildRequestBody = (embedMsg) => {
|
||||
return {
|
||||
embeds: [embedMsg],
|
||||
...(core.getInput('username') && { username: core.getInput('username') }),
|
||||
...(core.getInput('avatar_url') && { avatar_url: core.getInput('avatar_url') }),
|
||||
...(core.getInput('content') && { content: core.getInput('content') })
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Main function to handle the action: get inputs, format the message, and send the webhook.
|
||||
*/
|
||||
const run = async () => {
|
||||
const webhookUrl = core.getInput('webhook_url');
|
||||
if (!webhookUrl) return core.setFailed('webhook_url not set.');
|
||||
|
||||
const { body, html_url, name } = getContext();
|
||||
const description = formatDescription(body);
|
||||
|
||||
const embedMsg = buildEmbedMessage(name, html_url, description);
|
||||
|
||||
const requestBody = buildRequestBody(embedMsg);
|
||||
|
||||
await sendWebhook(webhookUrl, requestBody);
|
||||
};
|
||||
|
||||
run()
|
||||
.then(() => core.info('Action completed successfully'))
|
||||
.catch(err => core.setFailed(err.message));
|
||||
|
||||
+12
-12
@@ -1,22 +1,22 @@
|
||||
{
|
||||
"name": "github-release-to-discord",
|
||||
"version": "1.9.0",
|
||||
"lockfileVersion": 2,
|
||||
"name": "github-releases-to-discord",
|
||||
"version": "1.15.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@actions/core": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
||||
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
|
||||
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/github": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.0.3.tgz",
|
||||
"integrity": "sha512-myjA/pdLQfhUGLtRZC/J4L1RXOG4o6aYdiEq+zr5wVVKljzbFld+xv10k1FX6IkIJtNxbAq44BdwSNpQ015P0A==",
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||
"integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@octokit/core": "^3.6.0",
|
||||
@@ -230,9 +230,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "3.2.10",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz",
|
||||
"integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==",
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
||||
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
||||
"dependencies": {
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ const result = await core.group('Do something async', async () => {
|
||||
|
||||
This library has 3 methods that will produce [annotations](https://docs.github.com/en/rest/reference/checks#create-a-check-run).
|
||||
```js
|
||||
core.error('This is a bad error. This will also fail the build.')
|
||||
core.error('This is a bad error, action may still succeed though.')
|
||||
|
||||
core.warning('Something went wrong, but it\'s not bad enough to fail the build.')
|
||||
|
||||
@@ -163,7 +163,7 @@ export interface AnnotationProperties {
|
||||
startColumn?: number
|
||||
|
||||
/**
|
||||
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||
* The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||
* Defaults to `startColumn` when `startColumn` is provided.
|
||||
*/
|
||||
endColumn?: number
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ export declare enum ExitCode {
|
||||
Failure = 1
|
||||
}
|
||||
/**
|
||||
* Optional properties that can be sent with annotatation commands (notice, error, and warning)
|
||||
* Optional properties that can be sent with annotation commands (notice, error, and warning)
|
||||
* See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations.
|
||||
*/
|
||||
export interface AnnotationProperties {
|
||||
@@ -46,7 +46,7 @@ export interface AnnotationProperties {
|
||||
*/
|
||||
startColumn?: number;
|
||||
/**
|
||||
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||
* The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||
* Defaults to `startColumn` when `startColumn` is provided.
|
||||
*/
|
||||
endColumn?: number;
|
||||
|
||||
+17
-18
@@ -34,7 +34,6 @@ const file_command_1 = require("./file-command");
|
||||
const utils_1 = require("./utils");
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const uuid_1 = require("uuid");
|
||||
const oidc_utils_1 = require("./oidc-utils");
|
||||
/**
|
||||
* The code to exit an action
|
||||
@@ -64,20 +63,9 @@ function exportVariable(name, val) {
|
||||
process.env[name] = convertedVal;
|
||||
const filePath = process.env['GITHUB_ENV'] || '';
|
||||
if (filePath) {
|
||||
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
||||
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
|
||||
if (name.includes(delimiter)) {
|
||||
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
||||
}
|
||||
if (convertedVal.includes(delimiter)) {
|
||||
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
||||
}
|
||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
||||
file_command_1.issueCommand('ENV', commandValue);
|
||||
}
|
||||
else {
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
|
||||
}
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
}
|
||||
exports.exportVariable = exportVariable;
|
||||
/**
|
||||
@@ -95,7 +83,7 @@ exports.setSecret = setSecret;
|
||||
function addPath(inputPath) {
|
||||
const filePath = process.env['GITHUB_PATH'] || '';
|
||||
if (filePath) {
|
||||
file_command_1.issueCommand('PATH', inputPath);
|
||||
file_command_1.issueFileCommand('PATH', inputPath);
|
||||
}
|
||||
else {
|
||||
command_1.issueCommand('add-path', {}, inputPath);
|
||||
@@ -135,7 +123,10 @@ function getMultilineInput(name, options) {
|
||||
const inputs = getInput(name, options)
|
||||
.split('\n')
|
||||
.filter(x => x !== '');
|
||||
return inputs;
|
||||
if (options && options.trimWhitespace === false) {
|
||||
return inputs;
|
||||
}
|
||||
return inputs.map(input => input.trim());
|
||||
}
|
||||
exports.getMultilineInput = getMultilineInput;
|
||||
/**
|
||||
@@ -168,8 +159,12 @@ exports.getBooleanInput = getBooleanInput;
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function setOutput(name, value) {
|
||||
const filePath = process.env['GITHUB_OUTPUT'] || '';
|
||||
if (filePath) {
|
||||
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
|
||||
}
|
||||
process.stdout.write(os.EOL);
|
||||
command_1.issueCommand('set-output', { name }, value);
|
||||
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
|
||||
}
|
||||
exports.setOutput = setOutput;
|
||||
/**
|
||||
@@ -298,7 +293,11 @@ exports.group = group;
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function saveState(name, value) {
|
||||
command_1.issueCommand('save-state', { name }, value);
|
||||
const filePath = process.env['GITHUB_STATE'] || '';
|
||||
if (filePath) {
|
||||
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
|
||||
}
|
||||
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
|
||||
}
|
||||
exports.saveState = saveState;
|
||||
/**
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+2
-1
@@ -1 +1,2 @@
|
||||
export declare function issueCommand(command: string, message: any): void;
|
||||
export declare function issueFileCommand(command: string, message: any): void;
|
||||
export declare function prepareKeyValueMessage(key: string, value: any): string;
|
||||
|
||||
+19
-3
@@ -20,13 +20,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.issueCommand = void 0;
|
||||
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
|
||||
// We use any as a valid input type
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const uuid_1 = require("uuid");
|
||||
const utils_1 = require("./utils");
|
||||
function issueCommand(command, message) {
|
||||
function issueFileCommand(command, message) {
|
||||
const filePath = process.env[`GITHUB_${command}`];
|
||||
if (!filePath) {
|
||||
throw new Error(`Unable to find environment variable for file command ${command}`);
|
||||
@@ -38,5 +39,20 @@ function issueCommand(command, message) {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
}
|
||||
exports.issueCommand = issueCommand;
|
||||
exports.issueFileCommand = issueFileCommand;
|
||||
function prepareKeyValueMessage(key, value) {
|
||||
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
||||
const convertedValue = utils_1.toCommandValue(value);
|
||||
// These should realistically never happen, but just in case someone finds a
|
||||
// way to exploit uuid generation let's not allow keys or values that contain
|
||||
// the delimiter.
|
||||
if (key.includes(delimiter)) {
|
||||
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
||||
}
|
||||
if (convertedValue.includes(delimiter)) {
|
||||
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
||||
}
|
||||
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
|
||||
}
|
||||
exports.prepareKeyValueMessage = prepareKeyValueMessage;
|
||||
//# sourceMappingURL=file-command.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"file-command.js","sourceRoot":"","sources":["../src/file-command.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;;;;;;;;;;;;;;;;;;;AAEvC,mCAAmC;AACnC,uDAAuD;AAEvD,uCAAwB;AACxB,uCAAwB;AACxB,mCAAsC;AAEtC,SAAgB,YAAY,CAAC,OAAe,EAAE,OAAY;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAA;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,wDAAwD,OAAO,EAAE,CAClE,CAAA;KACF;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,sBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACjE,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAA;AACJ,CAAC;AAdD,oCAcC"}
|
||||
{"version":3,"file":"file-command.js","sourceRoot":"","sources":["../src/file-command.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;;;;;;;;;;;;;;;;;;;AAEvC,mCAAmC;AACnC,uDAAuD;AAEvD,uCAAwB;AACxB,uCAAwB;AACxB,+BAAiC;AACjC,mCAAsC;AAEtC,SAAgB,gBAAgB,CAAC,OAAe,EAAE,OAAY;IAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAA;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,wDAAwD,OAAO,EAAE,CAClE,CAAA;KACF;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,sBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACjE,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAA;AACJ,CAAC;AAdD,4CAcC;AAED,SAAgB,sBAAsB,CAAC,GAAW,EAAE,KAAU;IAC5D,MAAM,SAAS,GAAG,gBAAgB,SAAM,EAAE,EAAE,CAAA;IAC5C,MAAM,cAAc,GAAG,sBAAc,CAAC,KAAK,CAAC,CAAA;IAE5C,4EAA4E;IAC5E,6EAA6E;IAC7E,iBAAiB;IACjB,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,4DAA4D,SAAS,GAAG,CACzE,CAAA;KACF;IAED,IAAI,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,6DAA6D,SAAS,GAAG,CAC1E,CAAA;KACF;IAED,OAAO,GAAG,GAAG,KAAK,SAAS,GAAG,EAAE,CAAC,GAAG,GAAG,cAAc,GAAG,EAAE,CAAC,GAAG,GAAG,SAAS,EAAE,CAAA;AAC9E,CAAC;AApBD,wDAoBC"}
|
||||
+1
-1
@@ -44,7 +44,7 @@ class OidcClient {
|
||||
.catch(error => {
|
||||
throw new Error(`Failed to get ID Token. \n
|
||||
Error Code : ${error.statusCode}\n
|
||||
Error Message: ${error.result.message}`);
|
||||
Error Message: ${error.message}`);
|
||||
});
|
||||
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
||||
if (!id_token) {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3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E,CAAC,CAAA;gBAExC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;gBACvD,gBAAS,CAAC,QAAQ,CAAC,CAAA;gBACnB,OAAO,QAAQ,CAAA;aAChB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;aACnD;QACH,CAAC;KAAA;CACF;AAzED,gCAyEC"}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@actions/core",
|
||||
"version": "1.9.1",
|
||||
"version": "1.10.1",
|
||||
"description": "Actions core lib",
|
||||
"keywords": [
|
||||
"github",
|
||||
@@ -30,7 +30,7 @@
|
||||
"scripts": {
|
||||
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
"tsc": "tsc -p tsconfig.json"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
@@ -43,4 +43,4 @@
|
||||
"@types/node": "^12.0.2",
|
||||
"@types/uuid": "^8.3.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import * as Context from './context';
|
||||
import { GitHub } from './utils';
|
||||
import { OctokitOptions } from '@octokit/core/dist-types/types';
|
||||
import { OctokitOptions, OctokitPlugin } from '@octokit/core/dist-types/types';
|
||||
export declare const context: Context.Context;
|
||||
/**
|
||||
* Returns a hydrated octokit ready to use for GitHub Actions
|
||||
@@ -8,4 +8,4 @@ export declare const context: Context.Context;
|
||||
* @param token the repo PAT or GITHUB_TOKEN
|
||||
* @param options other options to set
|
||||
*/
|
||||
export declare function getOctokit(token: string, options?: OctokitOptions): InstanceType<typeof GitHub>;
|
||||
export declare function getOctokit(token: string, options?: OctokitOptions, ...additionalPlugins: OctokitPlugin[]): InstanceType<typeof GitHub>;
|
||||
|
||||
+3
-2
@@ -29,8 +29,9 @@ exports.context = new Context.Context();
|
||||
* @param token the repo PAT or GITHUB_TOKEN
|
||||
* @param options other options to set
|
||||
*/
|
||||
function getOctokit(token, options) {
|
||||
return new utils_1.GitHub(utils_1.getOctokitOptions(token, options));
|
||||
function getOctokit(token, options, ...additionalPlugins) {
|
||||
const GitHubWithPlugins = utils_1.GitHub.plugin(...additionalPlugins);
|
||||
return new GitHubWithPlugins(utils_1.getOctokitOptions(token, options));
|
||||
}
|
||||
exports.getOctokit = getOctokit;
|
||||
//# sourceMappingURL=github.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"github.js","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,mCAAiD;AAKpC,QAAA,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,CAAA;AAE5C;;;;;GAKG;AACH,SAAgB,UAAU,CACxB,KAAa,EACb,OAAwB;IAExB,OAAO,IAAI,cAAM,CAAC,yBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AACtD,CAAC;AALD,gCAKC"}
|
||||
{"version":3,"file":"github.js","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,mCAAiD;AAKpC,QAAA,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,CAAA;AAE5C;;;;;GAKG;AACH,SAAgB,UAAU,CACxB,KAAa,EACb,OAAwB,EACxB,GAAG,iBAAkC;IAErC,MAAM,iBAAiB,GAAG,cAAM,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC,CAAA;IAC7D,OAAO,IAAI,iBAAiB,CAAC,yBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AACjE,CAAC;AAPD,gCAOC"}
|
||||
+1
@@ -2,6 +2,7 @@ import * as Context from './context';
|
||||
import { Octokit } from '@octokit/core';
|
||||
import { OctokitOptions } from '@octokit/core/dist-types/types';
|
||||
export declare const context: Context.Context;
|
||||
export declare const defaults: OctokitOptions;
|
||||
export declare const GitHub: typeof Octokit & import("@octokit/core/dist-types/types").Constructor<import("@octokit/plugin-rest-endpoint-methods/dist-types/types").Api & {
|
||||
paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
|
||||
}>;
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getOctokitOptions = exports.GitHub = exports.context = void 0;
|
||||
exports.getOctokitOptions = exports.GitHub = exports.defaults = exports.context = void 0;
|
||||
const Context = __importStar(require("./context"));
|
||||
const Utils = __importStar(require("./internal/utils"));
|
||||
// octokit + plugins
|
||||
@@ -28,13 +28,13 @@ const plugin_rest_endpoint_methods_1 = require("@octokit/plugin-rest-endpoint-me
|
||||
const plugin_paginate_rest_1 = require("@octokit/plugin-paginate-rest");
|
||||
exports.context = new Context.Context();
|
||||
const baseUrl = Utils.getApiBaseUrl();
|
||||
const defaults = {
|
||||
exports.defaults = {
|
||||
baseUrl,
|
||||
request: {
|
||||
agent: Utils.getProxyAgent(baseUrl)
|
||||
}
|
||||
};
|
||||
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);
|
||||
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(exports.defaults);
|
||||
/**
|
||||
* Convience function to correctly format Octokit Options to pass into the constructor.
|
||||
*
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,w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AAM,GAAG,cAAO,CAAC,MAAM,CAClC,kDAAmB,EACnB,mCAAY,CACb,CAAC,QAAQ,CAAC,gBAAQ,CAAC,CAAA;AAEpB;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,KAAa,EACb,OAAwB;IAExB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,IAAI,EAAE,CAAC,CAAA,CAAC,iEAAiE;IAE/G,OAAO;IACP,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC7C,IAAI,IAAI,EAAE;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAbD,8CAaC"}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@actions/github",
|
||||
"version": "5.0.3",
|
||||
"version": "5.1.1",
|
||||
"description": "Actions github lib",
|
||||
"keywords": [
|
||||
"github",
|
||||
|
||||
+3
-2
@@ -147,7 +147,7 @@ export type RequestRedirect = 'error' | 'follow' | 'manual';
|
||||
export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
||||
export type RequestInfo = string | Request;
|
||||
export class Request extends BodyMixin {
|
||||
constructor(input: RequestInfo, init?: RequestInit);
|
||||
constructor(input: URL | RequestInfo, init?: RequestInit);
|
||||
|
||||
/**
|
||||
* Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
|
||||
@@ -196,6 +196,7 @@ export class Response extends BodyMixin {
|
||||
|
||||
static error(): Response;
|
||||
static redirect(url: string, status?: number): Response;
|
||||
static json(data: any, init?: ResponseInit): Response;
|
||||
}
|
||||
|
||||
export class FetchError extends Error {
|
||||
@@ -215,4 +216,4 @@ export class AbortError extends Error {
|
||||
}
|
||||
|
||||
export function isRedirect(code: number): boolean;
|
||||
export default function fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
|
||||
export default function fetch(url: URL | RequestInfo, init?: RequestInit): Promise<Response>;
|
||||
|
||||
+6
-5
@@ -269,8 +269,8 @@ It is common to create a helper function to check that the response contains no
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
class HTTPResponseError extends Error {
|
||||
constructor(response, ...args) {
|
||||
super(`HTTP Error Response: ${response.status} ${response.statusText}`, ...args);
|
||||
constructor(response) {
|
||||
super(`HTTP Error Response: ${response.status} ${response.statusText}`);
|
||||
this.response = response;
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,7 @@ console.log(response.headers.raw()['set-cookie']);
|
||||
### Post data using a file
|
||||
|
||||
```js
|
||||
import fetch {
|
||||
import fetch, {
|
||||
Blob,
|
||||
blobFrom,
|
||||
blobFromSync,
|
||||
@@ -539,7 +539,6 @@ If no values are set, the following request headers will be sent automatically:
|
||||
| ------------------- | ------------------------------------------------------ |
|
||||
| `Accept-Encoding` | `gzip, deflate, br` (when `options.compress === true`) |
|
||||
| `Accept` | `*/*` |
|
||||
| `Connection` | `close` _(when no `options.agent` is present)_ |
|
||||
| `Content-Length` | _(automatically calculated, if possible)_ |
|
||||
| `Host` | _(host and port information from the target URI)_ |
|
||||
| `Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ |
|
||||
@@ -558,6 +557,8 @@ The `agent` option allows you to specify networking related options which are ou
|
||||
|
||||
See [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information.
|
||||
|
||||
If no agent is specified, the default agent provided by Node.js is used. Note that [this changed in Node.js 19](https://github.com/nodejs/node/blob/4267b92604ad78584244488e7f7508a690cb80d0/lib/_http_agent.js#L564) to have `keepalive` true by default. If you wish to enable `keepalive` in an earlier version of Node.js, you can override the agent as per the following code sample.
|
||||
|
||||
In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol.
|
||||
|
||||
```js
|
||||
@@ -627,7 +628,7 @@ results in an [opaque-redirect filtered response](https://fetch.spec.whatwg.org/
|
||||
node-fetch gives you the typical [basic filtered response](https://fetch.spec.whatwg.org/#concept-filtered-response-basic) instead.
|
||||
|
||||
```js
|
||||
const fetch = require('node-fetch');
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
const response = await fetch('https://httpbin.org/status/301', { redirect: 'manual' });
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-fetch",
|
||||
"version": "3.2.10",
|
||||
"version": "3.3.2",
|
||||
"description": "A light-weight module that brings Fetch API to node.js",
|
||||
"main": "./src/index.js",
|
||||
"sideEffects": false,
|
||||
|
||||
-4
@@ -288,10 +288,6 @@ export const getNodeRequestOptions = request => {
|
||||
agent = agent(parsedURL);
|
||||
}
|
||||
|
||||
if (!headers.has('Connection') && !agent) {
|
||||
headers.set('Connection', 'close');
|
||||
}
|
||||
|
||||
// HTTP-network fetch step 4.2
|
||||
// chunked encoding is handled by Node.js
|
||||
|
||||
|
||||
+19
@@ -124,6 +124,25 @@ export default class Response extends Body {
|
||||
return response;
|
||||
}
|
||||
|
||||
static json(data = undefined, init = {}) {
|
||||
const body = JSON.stringify(data);
|
||||
|
||||
if (body === undefined) {
|
||||
throw new TypeError('data is not JSON serializable');
|
||||
}
|
||||
|
||||
const headers = new Headers(init && init.headers);
|
||||
|
||||
if (!headers.has('content-type')) {
|
||||
headers.set('content-type', 'application/json');
|
||||
}
|
||||
|
||||
return new Response(body, {
|
||||
...init,
|
||||
headers
|
||||
});
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
return 'Response';
|
||||
}
|
||||
|
||||
Generated
+26
-26
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"name": "github-release-to-discord",
|
||||
"version": "1.12.0",
|
||||
"name": "github-releases-to-discord",
|
||||
"version": "1.18.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "github-release-to-discord",
|
||||
"version": "1.12.0",
|
||||
"license": "ISC",
|
||||
"name": "github-releases-to-discord",
|
||||
"version": "1.18.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.9.1",
|
||||
"@actions/github": "^5.0.3",
|
||||
"node-fetch": "^3.2.10"
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/github": "^5.1.1",
|
||||
"node-fetch": "^3.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
||||
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
|
||||
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/github": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.0.3.tgz",
|
||||
"integrity": "sha512-myjA/pdLQfhUGLtRZC/J4L1RXOG4o6aYdiEq+zr5wVVKljzbFld+xv10k1FX6IkIJtNxbAq44BdwSNpQ015P0A==",
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||
"integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@octokit/core": "^3.6.0",
|
||||
@@ -240,9 +240,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "3.2.10",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz",
|
||||
"integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==",
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
||||
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
||||
"dependencies": {
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
@@ -320,18 +320,18 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
||||
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
|
||||
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
|
||||
"requires": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
},
|
||||
"@actions/github": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.0.3.tgz",
|
||||
"integrity": "sha512-myjA/pdLQfhUGLtRZC/J4L1RXOG4o6aYdiEq+zr5wVVKljzbFld+xv10k1FX6IkIJtNxbAq44BdwSNpQ015P0A==",
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||
"integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==",
|
||||
"requires": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@octokit/core": "^3.6.0",
|
||||
@@ -495,9 +495,9 @@
|
||||
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "3.2.10",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz",
|
||||
"integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==",
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
||||
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
||||
"requires": {
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
|
||||
+8
-11
@@ -1,12 +1,9 @@
|
||||
{
|
||||
"name": "github-release-to-discord",
|
||||
"version": "1.12.0",
|
||||
"description": "Github Action that parses a release and sends it to a Discord channel",
|
||||
"name": "github-releases-to-discord",
|
||||
"version": "1.18.0",
|
||||
"description": "A GitHub Action that automatically sends a stylized Discord webhook of a GitHub Release description to a specified Discord channel.",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
"discord",
|
||||
"github",
|
||||
@@ -20,13 +17,13 @@
|
||||
],
|
||||
"author": "SethCohen",
|
||||
"bugs": {
|
||||
"url": "https://github.com/SethCohen/github-release-to-discord/issues"
|
||||
"url": "https://github.com/SethCohen/github-releases-to-discord/issues"
|
||||
},
|
||||
"homepage": "https://github.com/SethCohen/github-release-to-discord#readme",
|
||||
"homepage": "https://github.com/SethCohen/github-releases-to-discord#readme",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.9.1",
|
||||
"@actions/github": "^5.0.3",
|
||||
"node-fetch": "^3.2.10"
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/github": "^5.1.1",
|
||||
"node-fetch": "^3.3.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"action": "published",
|
||||
"release": {
|
||||
"html_url": "https://example.com/releases/tag/v1.0.0",
|
||||
"name": "v1.0.0",
|
||||
"body": "## [1.0.0](https://example.com/compare/v0.9.0...v1.0.0) (1970-01-01)\n\n### Features\n* **core:** added initial release ([abc1234](https://example.com/commit/abc1234))\n* **api:** implemented endpoints ([def5678](https://example.com/commit/def5678))\n\n### Bug Fixes\n* **ui:** fixed button alignment ([#42](https://example.com/issues/42)) ([789abcd](https://example.com/commit/789abcd))\n\n### Miscellaneous\n* see [PR #7](https://example.com/pull/7) for details\n"
|
||||
},
|
||||
"repository": {
|
||||
"full_name": "example/repo",
|
||||
"html_url": "https://example.com/example/repo"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user