Coder Social home page Coder Social logo

pierluigi / actions-readme-feed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sarisia/actions-readme-feed

0.0 1.0 0.0 873 KB

Display RSS feed in your GitHub Profile README

Home Page: https://qiita.com/sarisia/items/630d53cee7976e36faa3

JavaScript 0.30% TypeScript 99.70%

actions-readme-feed's Introduction

Actions Readme Feed

Display RSS feed in your GitHub Profile README

Usage

First, add flag comments to where you want in your document:

### Latest Posts
<!-- feed start -->
<!-- feed end -->

Then add following steps to your workflow:

steps:
  - uses: actions/checkout@v2
  - uses: sarisia/actions-readme-feed@v1
    with:
      url: 'https://note.sarisia.cc/index.xml'
      file: 'README.md'
  - run: |
      git config --global user.name "${{ github.actor }}"
      git config --global user.email "${{ github.actor }}@users.noreply.github.com"
      git add .
      git commit -m "docs: update feed" || true
      git push

The result looks like:

Latest Posts

Inputs

Key Required Value Default Description
url Yes String URL of RSS feed (XML)
file Yes String Path to document file to process.
Can be relative path from repository root, or absolute path of Actions Runner.
sort Boolean true Sort feed entries by date in decending order.
max_entry Number 5 Number of feed entries to show
format String - ${monthshort} ${02day} - [${title}](${url}) Feed entry format string.
See Formatting for details.
start_flag String <!-- feed start --> Flag string to declare start of feed block
end_flag String <!-- feed end --> Flag string to declare end of feed block

Formatting

Examples below uses following RSS feed item:

<item>
  <title>Blog Post</title>
  <link>https://blog.example.com/blog-post</link>
  <pubDate>Sat, 05 Aug 2020 00:00:00 +0000</pubDate>
</item>

Variables

Key Example Note
title Blog Post
url https://blog.example.com/blog-post
year 2020 UTC
month 8 UTC
monthshort Aug UTC
monthlong August UTC
day 5 UTC
date 8/5/2020, 12:00:00 AM UTC

For details, see src/format.ts

Padding

You can padding variables with zeros or spaces.

Format Output Description
${2day} 5 Pads to length 2 with spaces
${05month} 00008 Pads to length 5 with zeros

Outputs

  • changed: Whether the document is changed while this actions's run. 1 if changed, 0 else.

  • items: Raw feed entry from rssparser.

    [
      {
        "title":"C.UTF-8 とは何だったのか",
        "link":"https://note.sarisia.cc/entry/what-is-c-utf8/","pubDate":"Fri, 21 Aug 2020 00:00:00 +0000",
        "content":"TL;DR 全ての Linux ディス...",
        "guid":"https://note.sarisia.cc/entry/what-is-c-utf8/",
        "isoDate":"2020-08-21T00:00:00.000Z"
      },
      ...
    ]
  • newlines: New lines inserted to the document specified as file. Lines are joined with \n.

    <!-- feed start -->
    - Aug 10 - [fish スクリプトのデバッグ](https://note.sarisia.cc/entry/debugging-fish-script/)
    - Aug 08 - [Arch Linux Install Battle](https://note.sarisia.cc/entry/arch-linux-install-battle/)
    - Aug 05 - [Linuxbrew で emscripten を導入する](https://note.sarisia.cc/entry/linuxbrew-emscripten/)
    - Jul 29 - [UWP アプリは localhost へ接続できない](https://note.sarisia.cc/entry/uwp-localhost/)
    - Jul 22 - [Linuxbrew で入れた Go でビルドしたバイナリは可搬性が無い](https://note.sarisia.cc/entry/linuxbrew-go/)
    <!-- feed end -->
    
  • result: Result document with feed lines inserted. Lines are joined with \n

    # Actions Readme Feed
    
    Display RSS feed in your [GitHub Profile README](https://docs.github.com/en/github/setting-up-and-managing-your-github-profile/managing-your-profile-readme)
    ...
    

Examples

Using changed output

changed output can be used directly in the if conditional.

steps:
  - uses: sarisia/actions-readme-feed@v1
    id: feed
    with:
      url: 'https://blog.example.com/feed.xml'
      file: 'README.md'
  - if: ${{ steps.feed.outputs.changed == true }}
    run: echo "changed!"

Update GitHub Profile README automatically

Make your workflow with schedule trigger.

on:
  schedule:
    - cron: '0 */6 * * *'

jobs:
  readme:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: sarisia/actions-readme-feed@v1
        id: feed
        with:
          url: 'https://note.sarisia.cc/index.xml'
          file: 'README.md'
      - if: ${{ steps.feed.outputs.changed == true }}
        run: |
          git config --global user.name "${{ github.actor }}"
          git config --global user.email "${{ github.actor }}@users.noreply.github.com"
          git add .
          git commit -m "docs: update feed"
          git push

Other sources (e.g. Qiita)

Not only Qiita, you can use any RSS feeds that rss-parser supports.

- uses: sarisia/actions-readme-feed@v1
  with:
    url: 'https://qiita.com/sarisia/feed'
    file: 'README.md'

Multiple feeds

Make sure to change start_flag and end_flag for each feed.

- name: blog
  uses: sarisia/actions-readme-feed@v1
  with:
    url: 'https://note.sarisia.cc/index.xml'
    file: 'README.md'
    start_flag: "<!-- blog start -->"
    end_flag: "<!-- blog end -->"
- name: qiita
  uses: sarisia/actions-readme-feed@v1
  with:
    url: 'https://qiita.com/sarisia/feed'
    file: 'README.md'
    start_flag: "<!-- qiita start -->"
    end_flag: "<!-- qiita end -->"
### Blog
<!-- blog start -->
<!-- blog end -->

### Qiita
<!-- qiita start -->
<!-- qiita end -->

actions-readme-feed's People

Contributors

dependabot[bot] avatar sarisia avatar

Watchers

 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.