LoginSignup
7
6

More than 3 years have passed since last update.

GitHub ActionsでRe:VIEW原稿をビルドする

Posted at

はじめに

Re:VIEWの開発環境をローカルに用意するの、しんどいですよね。
普段DockerやRubyを使わないのにこれらをインストールするのは億劫だと思います。

そんな方に、GitHub ActionsにRe:VIEWのビルド丸投げして楽しませんか?

注意
この記事の内容はTechBooster/ReVIEW-Templateのテンプレートを使用した場合の例です。

ワークフローファイル

以下の内容を.github/workflows以下のYAMLファイルにコピペしてリポジトリにPushしてください。
ここではpdf.ymlとして作成したとします。

.github/workflows/pdf.yml
name: Generate preview pdf
on: push

jobs:
  build:
    name: Generate pdf
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
        with:
          fetch-depth: 1
      - uses: docker://vvakame/review:4.0
      - run: ./build-in-docker.sh
      - name: Get build date
        id: get-date
        run: echo "::set-output name=date::$(date +"%Y-%m-%d")"
      - name: Get Repository Name
        id: get-repo-name
        run: echo "::set-output name=repo-name::${GITHUB_REPOSITORY##*/}"
      - uses: actions/upload-artifact@master
        with:
          name: ${{ steps.get-repo-name.outputs.repo-name }}-${{ steps.get-date.outputs.date }}
          # config.yml の bookname の値によって変える
          path: articles/output.pdf

また、プライベートリポジトリなどでなるべく実行回数を抑えたいという場合は、実行するファイルパスを明示的に指定してください。

on:
  push:
    paths:
      - articles/*
      - Gemfile
      - build-in-docker.sh
      - Gruntfile.js
      - package.json
      - rebuild-css.sh
      - setup.sh
      - .github/workflows/pdf.yml

機能

ワークフローが正常に終了すると、 <リポジトリ名>-<年月日> というアーティファクトが登録されます。
例:lollipop-onl/techbook-sampletechbook-sample-2020-01-10

アーティファクトのZIPファイル内にビルドされたPDFが入っているので、解凍してご覧ください。

また、プレビューしたい事にPushすることになるので、Commitが細かくなりリカバリがしやすくなる...かもしれません。

7
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6