Skip to content

Commit

Permalink
✨ Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Robdel12 committed Aug 8, 2024
0 parents commit 3cd21ec
Show file tree
Hide file tree
Showing 17 changed files with 53,548 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/actions/rss-checker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'RSS Monitor Action'
description: 'A reusable GitHub Action to monitor RSS feeds'

inputs:
rss-feeds:
description: 'Comma-separated list of RSS feed URLs to monitor'
required: true
default: ''
debug:
description: 'Enable debug mode'
required: false
default: false
commit-directory:
description: 'Directory to save the lastPublished.json file'
required: false
default: '.'
commit-message:
description: 'Commit message for changes to lastPublished.json'
required: false
default: '🤖 Update lastPublished.json'

runs:
using: 'node20'
main: '../../../dist/index.js'
18 changes: 18 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
summary.txt
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (3.0) Robert DeLuca

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# RSS Checker GitHub Action

## Overview

The RSS Checker GitHub Action is a reusable action designed to monitor a list of RSS feeds. It
checks for new articles, updates a JSON file with the latest published dates, and commits changes to
the repository if new articles are found. Additionally, it sets the GitHub Actions job to fail with
a summary of new articles detected.

## Usage

### Inputs

- `rss-feeds`: **Required**. A comma-separated list of RSS feed URLs to monitor.
- `commit-directory`: **Optional**. Directory to commit the `lastPublished.json` file. Defaults to the root of the repository.
- `commit-message`: **Optional**. Commit message for the update. Defaults to `🤖 Update lastPublished.json`.
- `debug`: **Optional**. Enable debug logging. Default is `false`.

### Example Workflow

Create a workflow file (e.g., `.github/workflows/rss-monitor.yml`) in your repository to use the custom action:

```yaml
name: RSS Feed Monitor

on:
schedule:
- cron: '*/45 * * * *' # Run every 45 minutes
workflow_dispatch:

jobs:
monitor:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run RSS-checker
uses: robdel12/rss-checker@v1.0.0
with:
rss-feeds: |
https://example.com/rss-feed1
https://example.com/rss-feed2
https://example.com/rss-feed3
https://example.com/rss-feed4
commit-directory: custom/dir
commit-message: Custom commit message
debug: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

```

### Notes

1. **Permissions**: Ensure your workflow has the required permissions to create and manage GitHub
Actions in your repository.
2. **GitHub Token**: The `GITHUB_TOKEN` secret is automatically provided by GitHub Actions, but you
must explicitly pass it in the `env` section.

### Outputs

This action does not have any direct outputs. It commits changes to the `lastPublished.json` file in
your repository and sets the job to fail if new articles are detected, providing a summary of new
articles in the GitHub Actions job summary. This approach is used to persist data across runs,
ensuring that the state is maintained over time, which is crucial for detecting new articles
reliably. Committing changes to the repository is the easiest solution to achieve this persistence.

### Debugging

Set the `debug` input to `true` to enable detailed debug logging, which can help troubleshoot any
issues with the action.

## License

This action is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
Loading

0 comments on commit 3cd21ec

Please sign in to comment.