Coder Social home page Coder Social logo

article-fetcher's Introduction

Article Fetcher

  • ZennQiitaから指定したユーザー ID の記事を取得する Github Action

使い方

前日の記事を取得する例

Zenn/Qiita のアカウントと名前を記載した json ファイルを作成

  • zenn-members.json
[
  {
    "id": "mk2",
    "name": "mk2"
  }
]
  • qiita-members.json
[
  {
    "id": "mk2",
    "name": "mk2"
  }
]

通知するためのスクリプトを用意

  • 例:notify.mjsというファイルを作成
npm i form-data got
import FormData from 'form-data';
import fs from 'fs';
import got from 'got';
import path from 'path';

const url = 'https://...';

async function main() {
  const dirname = path.dirname(new URL(import.meta.url).pathname);
  const data = await fs.promises.readFile(path.resolve(dirname, './articles.json'));
  const articles = JSON.parse(data);
  console.log(articles);
  for (const a of articles) {
    try {
      const body = new FormData();
      body.append('source', `${a.authorName} ${a.title} ${a.url} ${a.url}`);
      body.append('format', 'html');
      await got.post(url, { body });
    } catch (e) {
      console.error(e);
    }
  }
}

main();

GitHub アクションのワークフローを設定

  • 例:.github/workflows/notify.yamlというファイルを作成
name: Notify Zenn/Qiita Posts

on:
  workflow_dispatch:
  schedule:
    - cron: '00 3 * * *'

jobs:
  notify-job:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v2
        with:
          node-version: '14'
      - name: zenn/qiitaのユーザーIDリストの設定
        id: id-list-json
        run: |
          zenn=$(echo $(cat ./zenn-members.json))
          echo "::set-output name=zenn::$zenn"
          qiita=$(echo $(cat ./qiita-members.json))
          echo "::set-output name=qiita::$qiita"
      - uses: mk2/article-fetcher
        with:
          zenn: ${{ steps.id-list-json.outputs.zenn }}
          qiita: ${{ steps.id-list-json.outputs.qiita }}
          fromDaysAgo: 1
          qiitaAccessToken: ${{ secrets.QIITA_ACCESS_TOKEN }}
      - run: |
          node notify.mjs

開発環境

  • Node 12.x
  • Yarn v2

article-fetcher's People

Contributors

mk2 avatar renovate-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar

article-fetcher's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @types/jest to v26.0.24
  • chore(deps): update dependency eslint-import-resolver-node to v0.3.9
  • fix(deps): update dependency ansi-colors to v4.1.3
  • fix(deps): update dependency reflect-metadata to v0.2.2
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/download-artifact action to v4
  • chore(deps): update dependency @types/luxon to v3
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-config-prettier to v9
  • chore(deps): update dependency eslint-plugin-jest to v28
  • chore(deps): update dependency eslint-plugin-simple-import-sort to v12
  • chore(deps): update dependency ignore-sync to v7
  • chore(deps): update dependency mockttp to v3
  • chore(deps): update dependency prettier to v3
  • chore(deps): update dependency rimraf to v5
  • chore(deps): update dependency ts-node to v10
  • chore(deps): update dependency type-fest to v4
  • chore(deps): update dependency typescript to v5
  • chore(deps): update jest monorepo to v29 (major) (@types/jest, jest, jest-circus, ts-jest)
  • chore(deps): update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • fix(deps): update dependency @actions/artifact to v2
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/test-and-demo.yml
  • actions/checkout v2
  • actions/checkout v2
  • actions/download-artifact v2
npm
.yarn/sdks/eslint/package.json
.yarn/sdks/prettier/package.json
.yarn/sdks/typescript/package.json
package.json
  • @actions/artifact 0.5.0
  • @actions/core 1.2.6
  • ansi-colors 4.1.1
  • fast-xml-parser 3.18.0
  • luxon 1.26.0
  • node-fetch 2.6.1
  • reflect-metadata 0.1.13
  • ts-nested-error 1.2.1
  • @types/jest 26.0.20
  • @types/luxon 1.26.3
  • @types/node 14.14.31
  • @types/node-fetch 2.5.8
  • @typescript-eslint/eslint-plugin 4.15.1
  • @typescript-eslint/parser 4.15.1
  • @vercel/ncc 0.25.1
  • eslint 7.20.0
  • eslint-config-prettier 8.0.0
  • eslint-import-resolver-node 0.3.4
  • eslint-plugin-eslint-comments 3.2.0
  • eslint-plugin-github 4.1.1
  • eslint-plugin-import 2.22.1
  • eslint-plugin-jest 24.1.5
  • eslint-plugin-simple-import-sort 7.0.0
  • ignore-sync 3.1.0
  • jest 26.6.3
  • jest-circus 26.6.3
  • js-yaml 3.14.1
  • mockttp 1.2.0
  • prettier 2.2.1
  • rimraf 3.0.2
  • ts-jest 26.5.1
  • ts-node 9.1.1
  • type-fest 1.0.1
  • typescript 4.1.5

  • Check this box to trigger a request for Renovate to run again on this repository

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.