0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHub Actions の YAML 構文をスーパーライトにまとめとく

Last updated at Posted at 2025-10-02

用語の要約

  • Workflow(ワークフロー)
    .github/workflows/〇〇.yml に書く自動処理のまとまり
    on: の条件(push/PR/手動など)で起動

    ローカルからプッシュするときにトークンの権限が必要。
    注意:権限を付与してもオーナーでなければ、新規のymlファイルをローカルからプッシュできない可能性がある。更新はできそう。
    ローカルからプッシュができない場合:GitHubの上のタブActionsから作成はできた。

  • Job(ジョブ)
    同じランナー(実行するときのマシン)上で順番に実行される Step の束。ジョブごとに実行マシンを指定(runs-on: ubuntu-latest など)。ジョブ同士は needs: で依存関係を張れる。

  • Step(ステップ)
    ジョブ内の個々の手順

    • 既成のアクションを使う → uses: actions/checkout@v4
    • シェルを実行する → run: npm test
      ステップは上から順に実行され、同一のジョブ内では成果物を共有できる。

全体像

name: test

on:                       # ← on メインブランチにプルリクエストが作成、更新された時
  push:
    branches: [ main ]
  pull_request:

jobs:
  test:                   # ← Job(テスト)
    runs-on: ubuntu-latest
    steps:                # ← Step(手順)
      - uses: actions/checkout@v4
      - name: Set up Node
        uses: actions/setup-node@v4
        with: { node-version: 20 }
      - run: npm ci
      - run: npm test

  build:
    needs: test           # ← test が成功したら実行
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm run build

次回作成したymlファイルを汎用的に使えるようにして、復習ができるようにしておく。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?