Upgrade to Pro — share decks privately, control downloads, hide ads and more …

dev.toの記事もGitHubで管理してみた

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for YouYou YouYou
May 14, 2022

 dev.toの記事もGitHubで管理してみた

Avatar for YouYou

YouYou

May 14, 2022
Tweet

More Decks by YouYou

Other Decks in Technology

Transcript

  1. dev.toについて • 英語版Qiitaみたいなもの • 爆速であることで有名 ◦ 阿部寛さんのHPとどちらが速いか比較されたこともある • スマホアプリ版もある DEV

    is a community of software developers getting together to help one another out. The software industry relies on collaboration and networked learning. We provide a place for that to happen. Aboutページより引用 5
  2. GitHub Actionsワークフロー設定 deploy: # 長いので記事投稿部分のみ抜粋 name: Deploy if: github.ref == 'refs/heads/main'

    && github.event_name == 'push' runs-on: ubuntu-latest steps: - name: Checkout Repo uses: actions/checkout@master - name: Install Dependencies uses: bahmutov/npm-install@v1 - name: Deploy to dev.to run: DEV_TO_GIT_TOKEN=${{ secrets.DEV_TO_GIT_TOKEN }} yarn run dev-to-git Yarnパッケージ ↑参照 dev-to-gitにAPIキーを渡す 9
  3. 記事の初期作成 dev.toのAPIリクエストで作成する curl -X POST -H "Content-Type: application/json" \ -H

    "api-key: API_KEY" \ -d \ '{"article":{"title":"Template","body_markdown":"Body","published":false,"tags":["tag1", "tag2"]}}' https://dev.to/api/articles 環境変数でセット 10 Goで作った
  4. 記事IDの取得 curl -H "api-key: API_KEY" https://dev.to/api/articles/me/(un)published | \ jq '.[].id'

    プログラミング言語でも取得できますが、一部の言語では取得できませんでした。 例:Python dev-to-git.json 12