LoginSignup
3
4

More than 1 year has passed since last update.

GitHub Actions入門~サンプル作成・実行まで~

Last updated at Posted at 2022-07-20

GitHub Actionsとは

テストやビルド作業などの処理を自動化するGitHubの機能である

GitHub Actionsの無料枠(2022/7現在)

パブリックリポジトリは無料!

プライベートリポジトリの無料枠

プラン 1か月あたりの利用時間
Free 2,000分
Pro 3,000分
Team 3,000分
Enterprise 50,000分

GitHub Actionsを試してみる

実際にリポジトリを作成してサンプルを実行してみよう

リポジトリの作成

リポジトリを作成する
今回はお試しなので、Publicで作成する

image.png

設定ファイルの作成

GitHub Actionsを実行するためにはトリガーイベントや処理内容を記載したyamlファイルを作成する必要がある

  1. ルートディレクトリに.github/workflows/フォルダを作成する
  2. yamlファイル(sample.yaml)を作成する
  3. yamlファイルを下記の内容に編集する
  4. GitHubにpushする
sample.yaml
name: Sample

on:
  push:
    branches: 
      - main
  workflow_dispatch:

jobs:
  print-hello-world:
    runs-on: ubuntu-latest
    steps:
      - name: execute echo command
        run: echo "Hello World!"
git add .github/workflows/sample.yml
git commit -m "add sample"
git push

実行結果の確認

GitHubのActionsタブを開くとワークフローが成功していることが確認できる
image.png

中身を見るとHello World!が出力されているのが分かる
image.png

今回作成したリポジトリ

YAMLのテンプレート

MarketplaceにYAMLのテンプレートが用意されている

GitHub Marketplace · Actions to improve your workflow

参考

GitHub Actionsに入門する

3
4
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
3
4