Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play

GitHub Action

Article updater

v1.1.0

Article updater

play

Article updater

Collect articles then lists to README.md

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Article updater

uses: huantt/[email protected]

Learn more about this action in huantt/article-listing

Choose a version

About

Collect your latest articles from sources such as dev.to, and then update the README.md.

Use GitHub Action to update your README

Step 1: In your repository, create a file named README.md.template.

Step 2: Write anything you want within the README.md.template file.

Step 3: Embed one of the following entities within your README.md.template:

  • Article listing:
{{ template "article-list" .Articles }}

If you are familiar with Go templates, you have access to the root variable, which includes the following fields:

  • Articles: An array of Article. You can view the Article struct definition in model/article.go.
  • Time: Updated Time

Step 4: Register Github Action

  • Create a file .github/workflows/update-articles.yml in your repository.
name: "Cronjob"
on:
schedule:
- cron: '15 0 * * *'

jobs:
    update-articles:
        permissions: write-all
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v3
            - name: Generate README
              uses: huantt/[email protected]
              with:
                username: YOUR_USERNAME_ON_DEV_TO                
                template-file: 'README.md.template'
                out-file: 'README.md'
                limit: 5
            - name: Commit
              run: |
                git config user.name github-actions
                git config user.email [email protected]
                git add .
                git commit -m "update articles"
                git push origin main

Step 5: Commit your change, then Github actions will run as your specified cron to update Articles into your README.md file

Below is my recent articles Jack collected from dev.to

Updated at: 2023-09-13T13:14:26Z