Giter VIP home page Giter VIP logo

slackfeedbot's Introduction

SlackFeedBot

Push RSS feed updates to Slack via GitHub Actions

Sample output

How to use this Action

  1. Add the Incoming Webhooks app to your Slack workspace if you haven't already.
  2. Create a new webhook by clicking the Add to Slack button.
  3. Customize the webhook however you like, then copy the webhook URL.

Sample configuration

  1. Create a new workflow in your desired repository (e.g. .github/workflows/slackfeedbot.yml) and drop in the follwing:
name: SlackFeedBot
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  rss-to-slack:
    runs-on: ubuntu-latest
    steps:
      - name: NYT
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          interval: 15

Options

Required fields denoted with *. Must specify cache_dir (which requires separate use of actions/cache or a similar solution) or interval.

  • rss*: The RSS feed URL.
  • feed_name: A title to override the RSS feed's own title.
  • feed_image: An image to override the RSS feed's default feed image.
  • slack_webhook*: The Slack webhook URL (this can and probably should be a repository or organization secret).
  • cache_dir*: The folder in which to cache feed data, which prevents publishing duplicates, or alternately...
  • interval*: The number of minutes between runs of the parent workflow, as specified in the cron section of the schedule workflow trigger (may publish duplicates due to post pinning).
  • unfurl: Shows the Open Graph preview for RSS items instead of this action's display format. Set to false because it's kind of flaky and non-customizable. Use the below settings instead to customize display.
  • show_desc: Show the post description. Defaults to true.
  • show_img: Show the post image. Defaults to true.
  • show_date: Show the post date. Defaults to true.
  • show_link: Show the Read more link, linking back to the post. Defaults to true.

Examples

With cache folder (recommended)

Hashes and caches the post title + creation date to ensure no duplicates are posted.

name: SlackFeedBot
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  rss-to-slack:
    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: ./slackfeedbot-cache
          key: feed-cache-${{ steps.generate-key.outputs.cache-key }}
          restore-keys: feed-cache-
      - name: NYT
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          cache_dir: './slackfeedbot-cache'

With interval

No cache, but maybe duplicates.

name: SlackFeedBot
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  rss-to-slack:
    runs-on: ubuntu-latest
    steps:
      - name: NYT
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          interval: 15

Multiple feeds

name: FeedBot
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  rss-to-slack:
    runs-on: ubuntu-latest
    steps:
      - name: LAT
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://www.latimes.com/rss2.0.xml'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          interval: 15
      - name: WaPo
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://feeds.washingtonpost.com/rss/homepage'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          interval: 15

slackfeedbot's People

Contributors

dependabot[bot] avatar selfagency avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.