Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: publish to TG #134

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ed2ea31
ci: publish to TG
fadeev Sep 1, 2023
8e1576f
ci: on push
fadeev Sep 1, 2023
42be91b
use curl
fadeev Sep 1, 2023
107d69c
change text to trigger workflow
fadeev Sep 1, 2023
b44eb6b
workflow_dispatch
fadeev Sep 1, 2023
ccc7ea2
runs-on
fadeev Sep 1, 2023
9056b97
ci
fadeev Sep 1, 2023
7ea854d
added foo.md (#135)
fadeev Sep 1, 2023
97fd82a
fix ci
fadeev Sep 1, 2023
6a9feb9
test message (#136)
fadeev Sep 1, 2023
8ea4a81
pull request base
fadeev Sep 1, 2023
2861889
some text (#137)
fadeev Sep 1, 2023
82a7e47
fetch depth
fadeev Sep 1, 2023
4eaad98
Announcement four (#138)
fadeev Sep 1, 2023
e1aa29a
fetch depth again
fadeev Sep 1, 2023
53a029f
some text to publish (#139)
fadeev Sep 1, 2023
9ad7dcd
fetch depth once again
fadeev Sep 1, 2023
c4e9091
foo (#140)
fadeev Sep 1, 2023
75bd25b
fix
fadeev Sep 1, 2023
95d9335
remove announcements
fadeev Sep 1, 2023
ddb9039
text (#141)
fadeev Sep 1, 2023
50b8180
Announcement eight (#142)
fadeev Sep 1, 2023
f05c973
parse_mode
fadeev Sep 1, 2023
b678018
Publish something (#143)
fadeev Sep 1, 2023
3ff1aff
IFS
fadeev Sep 1, 2023
74e1f98
added two files (#144)
fadeev Sep 1, 2023
2999868
IFS
fadeev Sep 1, 2023
1270463
two files (#145)
fadeev Sep 1, 2023
ff9ce1b
another approach
fadeev Sep 1, 2023
e95e7d2
a12 (#146)
fadeev Sep 1, 2023
dbb5169
try again
fadeev Sep 1, 2023
f22fbfe
A13 (#147)
fadeev Sep 1, 2023
1528ff3
comma separated
fadeev Sep 1, 2023
526bd96
a14 (#148)
fadeev Sep 1, 2023
97374b9
fetch
fadeev Sep 1, 2023
8e28dbb
a15 (#149)
fadeev Sep 1, 2023
213a19d
only added files
fadeev Sep 1, 2023
9cf45d2
a16 (#150)
fadeev Sep 1, 2023
0c13e0e
Discord Webhooks
fadeev Sep 24, 2023
f8ccd47
13
fadeev Sep 24, 2023
2f6bebd
a16 (#157)
fadeev Sep 24, 2023
001640f
Fix Discord, convert to plain text
fadeev Sep 25, 2023
278f35a
rename
fadeev Sep 25, 2023
3f0fe61
a17 (#158)
fadeev Sep 25, 2023
401b097
markdown
fadeev Sep 25, 2023
2f2390e
a18 (#159)
fadeev Sep 25, 2023
2ae0317
error handling
fadeev Sep 25, 2023
0735203
a19 (#160)
fadeev Sep 25, 2023
ae1c691
handle 204 code
fadeev Sep 25, 2023
8a1996f
a20 (#161)
fadeev Sep 25, 2023
9d7aaba
html
fadeev Sep 25, 2023
4204283
a21 (#162)
fadeev Sep 25, 2023
bb11ebb
A22 (#163)
fadeev Sep 25, 2023
c0021b4
md
fadeev Sep 25, 2023
6e5a560
a23 (#164)
fadeev Sep 25, 2023
32cc43a
a24 (#165)
fadeev Sep 25, 2023
8b8aaac
escape md
fadeev Sep 25, 2023
d10bcfc
a25 (#166)
fadeev Sep 25, 2023
f359c4f
revert
fadeev Sep 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/announcements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Publish Blog Post to Telegram/Discord
on:
pull_request:
branches: [announcements]
types: [closed]
paths:
- "announcements/*.md"
jobs:
publish:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq curl pandoc

- name: Identify Markdown Files
id: files
run: |
base_sha=${{ github.event.pull_request.base.sha }}
head_sha=${{ github.event.pull_request.head.sha }}
git fetch origin $base_sha
git fetch origin $head_sha
files=$(git diff --name-only --diff-filter=A "$base_sha" "$head_sha" -- 'announcements/*.md')
files_comma_separated=$(echo "$files" | tr '\n' ',')
echo "Changed Markdown Files: $files_comma_separated"
echo "::set-output name=markdown_files::$files_comma_separated"

- name: Publish to Telegram/Discord
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }}
run: |
IFS=',' read -ra files_arr <<< "${{ steps.files.outputs.markdown_files }}"
for file in "${files_arr[@]}"; do
# Skip empty strings which may occur if there's a trailing comma
[ -z "$file" ] && continue
echo "Processing file: $file"

pandoc -f markdown -t plain "$file" -o "$file.txt"
content=$(cat "$file.txt")

response=$(curl -s -w "HTTPSTATUS:%{http_code}" -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" \
-d chat_id="${TELEGRAM_TO}" -d text="$content" -d parse_mode="Markdown")
http_status=$(echo "$response" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
if [ "$http_status" -ne 200 ] && [ "$http_status" -ne 204 ]; then
echo "Error sending to Telegram. HTTP Status: $http_status"
exit 1
fi

# Escape content for Discord JSON payload
escaped_content=$(echo "$content" | jq -Rs .)

response=$(curl -s -w "HTTPSTATUS:%{http_code}" -X POST -H "Content-Type: application/json" \
-d "{\"content\": $escaped_content}" https://discord.com/api/webhooks/1155501986532307056/POOHKkxip-2n4NA3Fe7ye1iPhrKeEwZOHiU2CSWCRt7TYv1uxvriNhZ0mat1JvLKpEsI)
http_status=$(echo "$response" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
if [ "$http_status" -ne 200 ] && [ "$http_status" -ne 204 ]; then
echo "Error sending to Discord. HTTP Status: $http_status"
exit 1
fi
done
3 changes: 3 additions & 0 deletions announcements/a16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test announcement

Nothing to see here.
6 changes: 6 additions & 0 deletions announcements/a17.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Test announcement

Nothing to see **here**.

- one
- two
6 changes: 6 additions & 0 deletions announcements/a18.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Test announcement

Nothing to see **here**.

- one
- two
6 changes: 6 additions & 0 deletions announcements/a19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Test announcement

Nothing to see **here**.

- one
- two
245 changes: 245 additions & 0 deletions announcements/a20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
---
__Advertisement :)__

- __[pica](https://nodeca.github.io/pica/demo/)__ - high quality and fast image
resize in browser.
- __[babelfish](https://github.com/nodeca/babelfish/)__ - developer friendly
i18n with plurals support and easy syntax.

You will like those projects!

---

# h1 Heading 8-)
## h2 Heading
### h3 Heading
#### h4 Heading
##### h5 Heading
###### h6 Heading


## Horizontal Rules

___

---

***


## Typographic replacements

Enable typographer option to see result.

(c) (C) (r) (R) (tm) (TM) (p) (P) +-

test.. test... test..... test?..... test!....

!!!!!! ???? ,, -- ---

"Smartypants, double quotes" and 'single quotes'


## Emphasis

**This is bold text**

__This is bold text__

*This is italic text*

_This is italic text_

~~Strikethrough~~


## Blockquotes


> Blockquotes can also be nested...
>> ...by using additional greater-than signs right next to each other...
> > > ...or with spaces between arrows.


## Lists

Unordered

+ Create a list by starting a line with `+`, `-`, or `*`
+ Sub-lists are made by indenting 2 spaces:
- Marker character change forces new list start:
* Ac tristique libero volutpat at
+ Facilisis in pretium nisl aliquet
- Nulla volutpat aliquam velit
+ Very easy!

Ordered

1. Lorem ipsum dolor sit amet
2. Consectetur adipiscing elit
3. Integer molestie lorem at massa


1. You can use sequential numbers...
1. ...or keep all the numbers as `1.`

Start numbering with offset:

57. foo
1. bar


## Code

Inline `code`

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code


Block code "fences"

```
Sample text here...
```

Syntax highlighting

``` js
var foo = function (bar) {
return bar++;
};

console.log(foo(5));
```

## Tables

| Option | Description |
| ------ | ----------- |
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |

Right aligned columns

| Option | Description |
| ------:| -----------:|
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |


## Links

[link text](http://dev.nodeca.com)

[link with title](http://nodeca.github.io/pica/demo/ "title text!")

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)


## Images

![Minion](https://octodex.github.com/images/minion.png)
![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg "The Stormtroopocat")

Like links, Images also have a footnote style syntax

![Alt text][id]

With a reference later in the document defining the URL location:

[id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat"


## Plugins

The killer feature of `markdown-it` is very effective support of
[syntax plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin).


### [Emojies](https://github.com/markdown-it/markdown-it-emoji)

> Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:
>
> Shortcuts (emoticons): :-) :-( 8-) ;)

see [how to change output](https://github.com/markdown-it/markdown-it-emoji#change-output) with twemoji.


### [Subscript](https://github.com/markdown-it/markdown-it-sub) / [Superscript](https://github.com/markdown-it/markdown-it-sup)

- 19^th^
- H~2~O


### [\<ins>](https://github.com/markdown-it/markdown-it-ins)

++Inserted text++


### [\<mark>](https://github.com/markdown-it/markdown-it-mark)

==Marked text==


### [Footnotes](https://github.com/markdown-it/markdown-it-footnote)

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote **can have markup**

and multiple paragraphs.

[^second]: Footnote text.


### [Definition lists](https://github.com/markdown-it/markdown-it-deflist)

Term 1

: Definition 1
with lazy continuation.

Term 2 with *inline markup*

: Definition 2

{ some code, part of Definition 2 }

Third paragraph of definition 2.

_Compact style:_

Term 1
~ Definition 1

Term 2
~ Definition 2a
~ Definition 2b


### [Abbreviations](https://github.com/markdown-it/markdown-it-abbr)

This is HTML abbreviation example.

It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.

*[HTML]: Hyper Text Markup Language

### [Custom containers](https://github.com/markdown-it/markdown-it-container)

::: warning
*here be dragons*
:::
Loading
Loading