Skip to content

Commit

Permalink
V1.6 (#23)
Browse files Browse the repository at this point in the history
* change workflow to use chain

* change workflow to use chain

* add copy of discord workflow

* github event objecting - testing

* github event objecting - testing

* update modules

* add resources to readme

* remove console logs
  • Loading branch information
ZebTheWizard authored Jan 29, 2023
1 parent b16ba24 commit a90470c
Show file tree
Hide file tree
Showing 1,096 changed files with 820,756 additions and 310,481 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/discord.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Discord

on:
- push

jobs:
disord_test_message:
runs-on: ubuntu-latest
name: discord commits
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Send message to discord
uses: ./ # Uses an action in the root directory
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
template: 'avatar-with-link'
include-extras: true
# message: "Successful commit to **{{ github.context.payload.repository.owner.name }}/{{ github.context.payload.repository.name}}**.\nDiff: {{ github.context.payload.compare }}"
# embed: '{ "title": "{{ commit.title }}", "description": "{{ commit.description }}", "url": "{{ commit.url }}", "author": { "name": "{{ commit.author.name }} ({{ commit.author.username }})", "icon_url": "https://github.com/{{ commit.author.username }}.png"} }'
# last-commit-only: true
23 changes: 23 additions & 0 deletions .github/workflows/entry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Entry

on:
workflow_run:
workflows:
- Discord
- Discord Copy
types:
- completed

jobs:
disord_test_message:
runs-on: ubuntu-latest
name: discord commits
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'yarn'
25 changes: 0 additions & 25 deletions .github/workflows/main.yml

This file was deleted.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Use markdown in your commit messages for nice formatting. As an example, here is

```yaml
- name: Discord Commits
uses: Sniddl/discord-commits@v1.5
uses: Sniddl/discord-commits@v1.6
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
template: 'avatar-with-link'
Expand Down Expand Up @@ -49,6 +49,10 @@ Option | Description
include-extras | Boolean - Include extra embeds from templates such as a link to the payload difference.
last-commit-only | Boolean - Only include the last commit.

## Resources
For information on the GitHub context API visit https://docs.github.com/en/actions/learn-github-actions/contexts
For information on the Discord Webhook API visit https://discord.com/developers/docs/resources/webhook

---

# Predefined templates
Expand Down
24 changes: 2 additions & 22 deletions discord-commits/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const extraEmbeds = stringToBoolean(core.getInput("include-extras")) ? template.

const embed = stringOrFalse(core.getInput("embed")) || JSON.stringify(template.embed)

console.log({ github })
console.log({ core })

const DATA = {
env: { ...process.env },
github: { ...github },
Expand All @@ -29,7 +26,6 @@ if (lastCommitOnly) {
}

let embeds = github.context.payload.commits.map(commit => {
console.log({ commit })
return parseTemplate({
...DATA,
commit: createCommit(commit),
Expand All @@ -43,23 +39,6 @@ const payload = {
embeds: embeds.filter(x => x)
}

// console.log(defaultPayload)

// const payload = {
// content: "Hello world",
// embeds: [
// {
// title: "Hello embed",
// description: "Hello embed description",
// // url: "https://google.com",
// author: {
// name: "Wade Zimmerman",
// // icon_url: "https://avatars.io/gravatar/[email protected]"
// }
// }
// ]
// }

try {
await fetch(`${webhook}?wait=true`, {
method: 'POST',
Expand All @@ -70,7 +49,8 @@ try {
body: JSON.stringify(payload)
})
} catch (err) {
console.error("Error:", err);
console.error(err)
core.error(err)
core.setFailed(
"Message :",
err.response ? err.response.data : err.message
Expand Down
99 changes: 0 additions & 99 deletions discord-commits/index.olf.js

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/semver

This file was deleted.

1 change: 1 addition & 0 deletions node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion node_modules/.bin/which

This file was deleted.

Loading

0 comments on commit a90470c

Please sign in to comment.