2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

CI/CDの学習の一環でGitHub Actionsに触れたのでまとめます。

GitHub Actions とは

例えば次のようなことを自動化できる。

  • push されたらテストを実行する
  • push されたらアプリをビルドする
  • ビルドが成功したら本番環境へデプロイする

コードを書いてpushするだけで、検証から公開まで自動で進む状態を作ることができる。

仕組み

YAMLファイルで定義します。

リポジトリのルート/
└── .github/
    └── workflows/
        └── helloworld.yml   ← ここに書く

実際に書いてみた

helloworld.yml
name: Hello World
on: push
jobs:
  say_hello:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Hello World!"

on には、ワークフローを動かすきっかけを指定する。

  • push … push したら自動で実行される
  • workflow_dispatch … Actions タブのボタンから手動で実行する

実行結果の確認

push後はリポジトリページの上部にある「Actions」タブから結果を確認できる。

まとめ

  • GitHub Actions は「リポジトリで起きたイベントを引き金に、自動で作業を実行する」仕組み
  • 設定は .github/workflows/内のYAMLファイルに書く
  • onpushworkflow_dispatch)を指定する
  • steps の中に実行したいコマンドを書く
  • 結果は「Actions」タブで確認できる
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?