SphinxとGitHub Actionsを使ってプレゼンの資料を作る

2020/03/07 Python東海 41th

私は

_images/comunity.jpg

内容

内容

Sphinxとは

Python製のドキュメント作成ツール

Restructuredtextやで記述して、HTML、PDF、Wordなど様々なフォーマットで出力が可能

Hint

Markdownでも書くことはできる

Sphinxとは

Sphinxは知らなくてもSphinxで作成されたものは必ず見ているはず

Sphinxとは

使い方は簡単

$ pip install sphinx
$ sphinx-quickstart

これでドキュメントを書くためのフォーマットが作成される

$ tree -L 1
.
├── Makefile
├── build
├── docs
├── make.bat
└── source
    ├── _static
    ├── _templates
    └── index.rst

Sphinxとは

選択するテンプレートによって先程のドキュメントサイトやこの資料のようなプレゼンテーションを作成できる

https://mursts.github.io/gcpug-nagoya-02/

内容

GitHub Actionsとは

GitHub上のイベントをトリガーとした(定期実行もあり)CI/CDのサービス

https://github.co.jp/features/actions

パブリックリポジトリは無料で、プライベートでも無料枠がある

GitHub Actionsの使い方

ワークフローを設定する

_images/github_actions_1.jpg

Hint

画面から作成しなくても、 .github/workflows にファイルを作成しても可

GitHub Actionsの使い方

_images/github_actions_2.jpg

GitHub Actionsの使い方

_images/github_actions_3.jpg

GitHub Actionsの使い方

トリガー

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

GitHub Actionsの使い方

ジョブ

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2

    # Runs a single command using the runners shell
    - name: Run a one-line script
      run: echo Hello, world!

    # Runs a set of commands using the runners shell
    - name: Run a multi-line script
      run: |
        echo Add other actions to build,
        echo test, and deploy your project.

GitHub Actionsの使い方

今回作ったWorkflow

https://raw.githubusercontent.com/mursts/python-tokai-41/master/.github/workflows/main.yml

name: Publish

on:
  push:
    branches: [ master ]

jobs:
  publish:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: 3.8
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Build sphinx
      run: make html
    - name: Deploy
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.ACTIONS_DEPLOY_KEY }}
        publish_dir: ./build/html

GitHub Actionsの使い方

トークンを設定する

  • GITHUB_TOKEN

    • Actionsを設定したときに自動でできるトークン

    • 今回はこれを使用した

  • DEPLOY_KEY

    • 自分で鍵を作ってGitHubに登録する

  • PERSONAL_TOKEN

    • settingsから作成するトークン

GitHub Actionsの使い方

準備ができたらrstファイルを編集してmasterにPush

内容

デモ

ご静聴ありがとうございました

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)