Skip to content

Commit

Permalink
let’s gooooooo
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Sieradski <[email protected]>
  • Loading branch information
selfagency committed Nov 16, 2022
1 parent e3ee4e8 commit 5a036f7
Show file tree
Hide file tree
Showing 18 changed files with 673 additions and 45 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/feedbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: FeedBot
on:
workflow_dispatch:
jobs:
rss-to-mastodon:
runs-on: ubuntu-latest
steps:
- name: Generate cache key
uses: actions/github-script@v6
id: generate-key
with:
script: |
core.setOutput('cache-key', new Date().valueOf())
- name: Retrieve cache
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/mastofeedbot
key: feed-cache-i-${{ steps.generate-key.outputs.cache-key }}
restore-keys: feed-cache-i-
- name: GitHub
uses: 'selfagency/slackfeedbot@main'
with:
rss-feed: https://www.githubstatus.com/history.rss
api-endpoint: https://kibitz.cloud/api/v1/
api-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
cache-file: ${{ github.workspace }}/mastofeedbot/cache.json
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 16

- name: Check package version
id: check
uses: 'EndBug/version-check@v1'
with:
token: ${{ secrets.GITHUB_TOKEN }}
diff-search: true

# - name: Generate changelog
# id: changelog
# uses: 'mikepenz/release-changelog-builder-action@v2'
# if: ${{ steps.check.outputs.changed == 'true' }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# continue-on-error: true

- name: Create release
uses: 'zendesk/action-create-release@v1'
if: ${{ steps.check.outputs.changed == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.check.outputs.version}}
# body: ${{ steps.changelog.outputs.changelog }}
release_name: v${{ steps.check.outputs.version}}
draft: false
prerelease: false
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
.LSOverride

# Icon must end with two \r
Icon
Icon


# Thumbnails
._*
Expand Down Expand Up @@ -144,7 +145,6 @@ out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
Expand Down
2 changes: 1 addition & 1 deletion .idea/vcs.xml

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

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Mastofeedbot

Mastofeedbot is a bot that posts RSS feeds to Mastodon via GitHub Actions.

## Usage

```yaml
name: FeedBot
on:
schedule:
- cron: '*/5 * * * *'
jobs:
rss-to-mastodon:
runs-on: ubuntu-latest
steps:
- name: Generate cache key
uses: actions/github-script@v6
id: generate-key
with:
script: |
core.setOutput('cache-key', new Date().valueOf())
- name: Retrieve cache
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/mastofeedbot
key: feed-cache-${{ steps.generate-key.outputs.cache-key }}
restore-keys: feed-cache-
- name: GitHub
uses: 'selfagency/slackfeedbot@main'
with:
rss-feed: https://www.githubstatus.com/history.rss
api-endpoint: https://mastodon.social
api-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
cache-file: ${{ github.workspace }}/mastofeedbot/cache.json
```
26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'MastoFeedBot'
author: 'selfagency'
description: 'Push RSS feed updates to Mastodon via GitHub Actions'
branding:
icon: 'rss'
color: 'orange'
inputs:
rss-feed:
description: 'RSS feed URL'
required: true
cache-file:
description: 'Cache file'
required: true
cache-limit:
description: 'Cache limit'
required: false
default: '100'
api-endpoint:
description: 'Mastodon API endpoint'
required: true
api-token:
description: 'Mastodon access token'
required: true
runs:
using: 'node16'
main: 'dist/index.js'
53 changes: 53 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@selfagency/mastofeedbot",
"version": "0.1.0",
"description": "A bot to syndicate RSS to Mastodon via GitHub Actions",
"author": "Daniel Sieradski <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/selfagency/mastofeedbot.git"
},
"keywords": [
"mastodon",
"fediverse",
"bot",
"rss"
],
"bugs": {
"url": "https://github.com/selfagency/mastofeedbot/issues"
},
"homepage": "https://github.com/selfagency/mastofeedbot#readme",
"type": "module",
"main": "dist/index.js",
"scripts": {
"build": "node --es-module-specifier-resolution node esbuild.js"
},
"devDependencies": {
"@types/feedparser": "^2.2.5",
"@types/node": "^18.11.9",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"esbuild": "^0.15.14",
"esbuild-plugin-clean": "^0.9.0",
"esbuild-plugin-copy-file": "^0.0.2",
"esbuild-plugin-fileloc": "^0.0.6",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^17.0.0",
"prettier": "^2.7.1",
"typescript": "^4.9.3"
},
"dependencies": {
"@actions/core": "^1.10.0",
"@sohailalam2/abu": "^0.4.0",
"masto": "^4.6.2",
"rss-url-parser": "^2.2.4"
}
}
45 changes: 45 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import fileloc from 'esbuild-plugin-fileloc';
import { clean } from 'esbuild-plugin-clean';
import copyFilePlugin from 'esbuild-plugin-copy-file';
import esbuild from 'esbuild';

const banner = `
import {createRequire} from 'module';
const require = createRequire(import.meta.url);
`;

esbuild
.build({
entryPoints: ['./src/index.ts'],
platform: 'node',
target: 'node16',
bundle: true,
plugins: [
clean({
patterns: ['./dist/*']
}),
fileloc.filelocPlugin(),
copyFilePlugin({
after: {
'./dist/package.json': './package.json'
}
})
],
loader: {
'.ts': 'ts',
'.js': 'js',
'.cjs': 'js'
},
outdir: 'dist',
external: ['package.json'],
minify: true,
sourcemap: true,
format: 'esm',
banner: {
js: banner
}
})
.catch(error => {
console.error(error.message);
process.exit(1);
});
Loading

0 comments on commit 5a036f7

Please sign in to comment.