Help us understand the problem. What is going on with this article?

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

はじめに

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が細かくなりリカバリがしやすくなる...かもしれません。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away