GitHub Actions

on:
  push:
    branches:
      - main

defaults:
  run:
    working-directory: backend

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/stepup-node@v3
        with:
          node-version: 16.x

      - run: npm ci
      - run: npm run test
      - run: npm run build

GitHub Actionsとは?

  • pullやpull-requestといった、Gitで固有の「アクション」を実行トリガーとして、何らかの動作が定義できる。
  • 主にCI/CDを実現するためにGithubが提供している機能。Github上の何らかのアクションに応じた動作を定義できる。
  • 例えば「git pushした場合に自動的に環境をビルドし、実環境にデプロイする」とか「自動テストを定義しておき、定期的に環境に対して実行する」など
  • "GitHub Actions は、ビルド、テスト、デプロイのパイプラインを自動化できる継続的インテグレーションと継続的デリバリー (CI/CD) のプラットフォームです。(以下略)" (GitHub Actions 公式より)
#リポジトリを作成
mkdir github-actions-sample
cd github-actions-sample

#指定のディレクトリを作成
mkdir -p .github/workflows

#ワークフローを作成
vi .github/workflows/learn-github-actions.yml
name: learn-github-actions
on: [push]
jobs:
    check-bats-versions:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v2
            - uses: actions/setup-node@v1
            - run: yarn add -g bats
            - run: bats -v
npm run test -- --coverage

https://github.com/documentationjs/documentation

documentation --help
documentation build pages/[a-zA-Z]*\.tsx -f md --github -o pages/docs.md