はじめに
GitHub Actions ワークフローを作成して実行するには、既存の GitHub リポジトリのみが必要です。 このガイドでは、GitHubSuper-Linter アクションを使用して複数のコーディング言語の文法チェックを行うワークフローを追加します。 ワークフローは Super-Linter を使用して、新しいコミットがリポジトリにプッシュされるたびにソースコードを検証します。
最初のワークフローを作成する
-
GitHub のリポジトリから、
superlinter.yml
という名前の新しいファイルを.github/workflows
ディレクトリに作成します。 詳細は「新しいファイルを作成する」を参照してください。 -
次の YAML コンテンツを
superlinter.yml
ファイルにコピーします。 注釈: デフォルトブランチがmain
でない場合は、リポジトリのデフォルトブランチ名と一致するようにDEFAULT_BRANCH
の値を更新してください。YAML name: Super-Linter # 新しいコミットがリポジトリにプッシュされるたびにこのワークフローを実行する on: push jobs: # ジョブキーを設定する。 ジョブ名が指定されていない場合、 # キーはジョブ名として表示される super-lint: # ジョブ名を付ける name: Lint code base # 実行するマシンのタイプを設定する runs-on: ubuntu-latest steps: # ubuntu-latest マシンでリポジトリのコピーをチェックアウトする - name: Checkout code uses: actions/checkout@v2 # Super-Linter アクションを実行する - name: Run Super-Linter uses: github/super-linter@v3 env: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
ワークフローを実行するには、ページの一番下までスクロールし、[Create a new branch for this commit and start a pull request] を選択します。 次に、[Propose new file] をクリックしてプルリクエストを作成します。
リポジトリ内のワークフローファイルをコミットすると、push
イベントがトリガーされ、ワークフローが実行されます。
ワークフローの結果を表示する
-
GitHubで、リポジトリのメインページにアクセスしてください。
-
リポジトリ名の下でActions(アクション)をクリックしてください。
-
左のサイドバーで、表示させたいワークフローをクリックしてください。
-
From the list of workflow runs, click the name of the run you want to see.
-
Under Jobs or in the visualization graph, click the Lint code base job.
-
Any failed steps are automatically expanded to display the results.
More workflow templates
GitHub provides preconfigured workflow templates that you can customize to create your own continuous integration workflow. GitHub analyzes your code and shows you CI templates that might be useful for your repository. たとえばリポジトリにNode.jsのコードが含まれているなら、Node.jsプロジェクトのためのサジェッションが提示されます。 ワークフローテンプレートは、カスタムワークフローの構築の出発点として利用することも、そのまま利用することもできます。
actions/starter-workflows リポジトリ。
次のステップ
追加した super-linter ワークフローは、コードがリポジトリにプッシュされるたびに実行され、コードのエラーや不整合を見つけます。 ただし、これは GitHub Actions でできることの一部にすぎません。 リポジトリには、さまざまなイベントに基づいてさまざまなジョブをトリガーする複数のワークフローを含めることができます。 GitHub Actions は、アプリケーション開発プロセスのほぼすべての要素を自動化するのに役立ちます。 開始する場合、 GitHub Actions で次のステップに進む際に役立つ、以下のようなリソースを参照してください。
- 詳細なチュートリアルは、「GitHub Actionsを学ぶ」
- 特定の使用例とサンプルについては、「ガイド」
- Super-Linter アクションの設定の詳細については、github/super-linter
Introduction
Printing "Hello, World!" is a great way to explore the basic set up and syntax of a new programming language. In this guide, you'll use GitHub Actions to print "Hello, World!" within your GitHub repository's workflow logs. All you need to get started is a GitHub repository where you feel comfortable creating and running a sample GitHub Actions workflow. Feel free to create a new repository for this Quickstart, you can use it to test this and future GitHub Actions workflows.
Creating your first workflow
-
From your repository on GitHub, create a new file in the
.github/workflows
directory namedhello-world.yml
. For more information, see "Creating new files." -
Copy the following YAML contents into the
hello-world.yml
file.YAML name: Say hello! # GitHub Actions Workflows are automatically triggered by GitHub events on: # For this workflow, we're using the workflow_dispatch event which is triggered when the user clicks Run workflow in the GitHub Actions UI workflow_dispatch: # The workflow_dispatch event accepts optional inputs so you can customize the behavior of the workflow inputs: name: description: 'Person to greet' required: true default: 'World' # When the event is triggered, GitHub Actions will run the jobs indicated jobs: say_hello: # Uses a ubuntu-latest runner to complete the requested steps runs-on: ubuntu-latest steps: - run: | echo "Hello ${{ github.event.inputs.name }}!"
-
Scroll to the bottom of the page and select Create a new branch for this commit and start a pull request. Then, to create a pull request, click Propose new file.
-
Once the pull request has been merged, you'll be ready to move on to "Trigger your workflow".
Trigger your workflow
- GitHubで、リポジトリのメインページにアクセスしてください。
- リポジトリ名の下でActions(アクション)をクリックしてください。
- In the left sidebar, click the workflow you want to run.
- On the right, click the Run workflow drop-down and click Run workflow. Optionally, you can enter a custom message into the "Person to greet" input before running the workflow.
- The workflow run will appear at the top of the list of "Say hello!" workflow runs. Click "Say hello!" to see the result of the workflow run.
- In the left sidebar, click the "say_hello" job.
- In the workflow logs, expand the 'Run echo "Hello World!"' section.
More workflow templates
GitHub provides preconfigured workflow templates that you can customize to create your own continuous integration workflow. GitHub analyzes your code and shows you CI templates that might be useful for your repository. たとえばリポジトリにNode.jsのコードが含まれているなら、Node.jsプロジェクトのためのサジェッションが提示されます。 ワークフローテンプレートは、カスタムワークフローの構築の出発点として利用することも、そのまま利用することもできます。
actions/starter-workflows リポジトリ。
Next steps
The hello-world workflow you just added is a simple example of a manually triggered workflow. This is only the beginning of what you can do with GitHub Actions. リポジトリには、さまざまなイベントに基づいてさまざまなジョブをトリガーする複数のワークフローを含めることができます。 GitHub Actions は、アプリケーション開発プロセスのほぼすべての要素を自動化するのに役立ちます。 開始する場合、 Here are some helpful resources for taking your next steps with GitHub Actions:
- "Learn GitHub Actions" for an in-depth tutorial
- "Guides" for specific uses cases and examples