Skip to main content
ドキュメントには� �繁に更新が� えられ、その都度公開されています。本ページの翻訳はま� 未完成な部分があることをご了承く� さい。最新の情� �については、英語のドキュメンテーションをご参照く� さい。本ページの翻訳に問題がある� �合はこちらまでご連絡く� さい。

このバージョンの GitHub Enterprise はこの日付をもって終了となりました: 2022-06-03. 重大なセキュリティの問題に対してであっても、パッチリリースは作成されません。 パフォーマンスの向上、セキュリティの改善、新機能のためには、最新バージョンのGitHub Enterpriseにアップグレードしてく� さい。 アップグレードに関する支援については、GitHub Enterprise supportに連絡してく� さい。

コンテキスト

You can access context information in workflows and actions.

ノート: GitHubホストランナーは、現在GitHub Enterprise Serverでサポートされていません。 GitHubパブリックロードマップで、計画されている将来のサポートに関する詳しい情� �を見ることができます。

About contexts

コンテキストは、ワークフローの実行、ランナーの環境、ジョブ、ステップに関する情� �にアクセスする方法です。 Each context is an object that contains properties, which can be strings or other objects.

Contexts, objects, and properties will vary significantly under different workflow run conditions. For example, the matrix context is only populated for jobs in a matrix.

You can access contexts using the expression syntax. For more information, see "Expressions."

${{ <context> }}

警告: ワークフローやアクションを作る際には、攻撃者からの信� �できない入力をコードが実行するかもしれないことを、常に意識しなければなりません。 攻撃者が悪意あるコンテンツを挿入してくるかもしれないので、特定のコンテキストは信� �できない入力として扱うべきです。 詳しい情� �については「スクリプトインジェクションのリスクを理解する」を参照してく� さい。

コンテキスト名種類説明
githubオブジェクトワークフロー実行に関する情� �。 詳しい情� �については、「github コンテキスト」を参照してく� さい。
envオブジェクトワークフロー、ジョブ、ステップで設定された環境変数が含まれます。 詳しい情� �については、env コンテキストを参照してく� さい。
ジョブオブジェクトInformation about the currently running job. 詳しい情� �については、「job コンテキスト」を参照してく� さい。
stepsオブジェクトInformation about the steps that have been run in the current job. 詳しい情� �については、「steps コンテキスト」を参照してく� さい。
runnerオブジェクト現在のジョブを実行している runner に関する情� �。 詳しい情� �についてはrunnerコンテキストを参照してく� さい。
secretsオブジェクトContains the names and values of secrets that are available to a workflow run. For more information, see secrets context.
strategyオブジェクトInformation about the matrix execution strategy for the current job. For more information, see strategy context.
matrixオブジェクトContains the matrix properties defined in the workflow that apply to the current job. For more information, see matrix context.
needsオブジェクトContains the outputs of all jobs that are defined as a dependency of the current job. 詳しい情� �についてはneedsコンテキストを参照してく� さい。

As part of an expression, you can access context information using one of two syntaxes.

  • インデックス構文: github['sha']
  • プロパティ参照外しの構文: github.sha

In order to use property dereference syntax, the property name must start with a letter or _ and contain only alphanumeric characters, -, or _.

If you attempt to dereference a non-existent property, it will evaluate to an empty string.

コンテキストを使用する� �合の判断

GitHub Actionsは、コンテキストと呼ばれる変数の集合と、デフォルトの環境変数と呼ばれる同様の変数の集合を含みます。 これらの変数は、ワークフロー中の様々な� �所で利用されることを意図したものです。

  • デフォルトの環境変数: これらの変数は、ジョブを実行しているランナー上にのみ存在します。 詳しい情� �については、「デフォルトの環境変数」を参照してく� さい。
  • コンテキスト: ほとんどのコンテキストはワークフローの任意の� �所で利用できます。これは、デフォルトの環境変数が利用できない� �所も含みます。 たとえば、式の付いたコンテキストを使って、ジョブが実行のためにランナーにまわされる前に初期の処理を行うことができます。これによって、ステップを実行すべきかを判断するために条件のifキーワード付きのコンテキストが利用できるようになります。 ジョブが実行されると、runner.osといったように、コンテキスト変数をジョブを実行しているランナーから取り出すこともできます。 ワークフロー中で様々なコンテキストが利用できる� �所の詳細については「コンテキストが利用できるところ」を参照してく� さい。

以下の例は、様々な種類の環境変数をジョブの中で合わせて利用できることを示しています。

name: CI
on: push
jobs:
  prod-check:
    if: ${{ github.ref == 'refs/heads/main' }}
    runs-on: ubuntu-latest
    steps:
      - run: echo "Deploying to production server on branch $GITHUB_REF"

この例では、if文がgithub.refコンテキストをチェックして現在のブランチ名を判断しています。その名前がrefs/heads/mainであれば、以降のステップが実行されます。 このifチェックがGitHub Actionsで処理されたなら、その結果がtrueの� �合にのみジョブがランナーに送信されます。 ジョブがランナーに送信されると、ステップが実行され、環境変数の$GITHUB_REFをランナーから参照します。

Context availability

Different contexts are available throughout a workflow run. For example, the secrets context may only be used at certain places within a job.

In addition, some functions may only be used in certain places. For example, the hashFiles function is not available everywhere.

The following table indicates where each context and special function can be used within a workflow. Unless listed below, a function can be used anywhere. | | パス | コンテキスト | Special functions | | --------------------------- | --------------------------- | --------------------------- | | concurrency | github | | | env | github, secrets | | | jobs.<job_id>.concurrency | github, needs, strategy, matrix | | | jobs.<job_id>.container | github, needs, strategy, matrix | | | jobs.<job_id>.container.credentials | github, needs, strategy, matrix, env, secrets | | | jobs.<job_id>.container.env.<env_id> | github, needs, strategy, matrix, job, runner, env, secrets | | | jobs.<job_id>.continue-on-error | github, needs, strategy, matrix | | | jobs.<job_id>.defaults.run | github, needs, strategy, matrix, env | | | jobs.<job_id>.env | github, needs, strategy, matrix, secrets | | | jobs.<job_id>.environment | github, needs, strategy, matrix | | | jobs.<job_id>.environment.url | github, needs, strategy, matrix, job, runner, env, steps | | | jobs.<job_id>.if | github, needs | always, cancelled, success, failure | | jobs.<job_id>.name | github, needs, strategy, matrix | | | jobs.<job_id>.outputs.<output_id> | github, needs, strategy, matrix, job, runner, env, secrets, steps | | | jobs.<job_id>.runs-on | github, needs, strategy, matrix | | | jobs.<job_id>.services | github, needs, strategy, matrix | | | jobs.<job_id>.services.<service_id>.credentials | github, needs, strategy, matrix, env, secrets | | | jobs.<job_id>.services.<service_id>.env.<env_id> | github, needs, strategy, matrix, job, runner, env, secrets | | | jobs.<job_id>.steps.continue-on-error | github, needs, strategy, matrix, job, runner, env, secrets, steps | hashFiles | | jobs.<job_id>.steps.env | github, needs, strategy, matrix, job, runner, env, secrets, steps | hashFiles | | jobs.<job_id>.steps.if | github, needs, strategy, matrix, job, runner, env, steps | always, cancelled, success, failure, hashFiles | | jobs.<job_id>.steps.name | github, needs, strategy, matrix, job, runner, env, secrets, steps | hashFiles | | jobs.<job_id>.steps.run | github, needs, strategy, matrix, job, runner, env, secrets, steps | hashFiles | | jobs.<job_id>.steps.timeout-minutes | github, needs, strategy, matrix, job, runner, env, secrets, steps | hashFiles | | jobs.<job_id>.steps.with | github, needs, strategy, matrix, job, runner, env, secrets, steps | hashFiles | | jobs.<job_id>.steps.working-directory | github, needs, strategy, matrix, job, runner, env, secrets, steps | hashFiles | | jobs.<job_id>.strategy | github, needs | | | jobs.<job_id>.timeout-minutes | github, needs, strategy, matrix | |

Example: printing context information to the log

You can print the contents of contexts to the log for debugging. The toJSON function is required to pretty-print JSON objects to the log.

警告: githubコンテキスト全体を使う� �合には、github.tokenのようなセンシティブな情� �が含まれていることを忘れないようにしてく� さい。 GitHubは、シークレットがコンソールに出力される際にはマスクしますが、コンテキストをエクスポートしたりプリントしたりするときには注意が必要です。

YAML
name: Context testing
on: push

jobs:
  dump_contexts_to_log:
    runs-on: ubuntu-latest
    steps:
      - name: Dump GitHub context
        id: github_context_step
        run: echo '${{ toJSON(github) }}'
      - name: Dump job context
        run: echo '${{ toJSON(job) }}'
      - name: Dump steps context
        run: echo '${{ toJSON(steps) }}'
      - name: Dump runner context
        run: echo '${{ toJSON(runner) }}'
      - name: Dump strategy context
        run: echo '${{ toJSON(strategy) }}'
      - name: Dump matrix context
        run: echo '${{ toJSON(matrix) }}'

github コンテキスト

github コンテキストは、ワークフローの実行および、その実行をトリガーしたイベントの情� �を含みます。 You can also read most of the github context data in environment variables. 環境変数に関する詳しい情� �については、「環境変数の利用」を参照してく� さい。

警告: githubコンテキスト全体を使う� �合には、github.tokenのようなセンシティブな情� �が含まれていることを忘れないようにしてく� さい。 GitHubは、シークレットがコンソールに出力される際にはマスクしますが、コンテキストをエクスポートしたりプリントしたりするときには注意が必要です。

警告: ワークフローやアクションを作る際には、攻撃者からの信� �できない入力をコードが実行するかもしれないことを、常に意識しなければなりません。 攻撃者が悪意あるコンテンツを挿入してくるかもしれないので、特定のコンテキストは信� �できない入力として扱うべきです。 詳しい情� �については「スクリプトインジェクションのリスクを理解する」を参照してく� さい。

プロパティ名種類説明
githubオブジェクトワークフローのあらゆるジョブやステップにおいて使用できる最上位のコンテキスト。 This object contains all the properties listed below.
github.actionstringThe name of the action currently running, or the id of a step. GitHub removes special characters, and uses the name __run when the current step runs a script without an id. If you use the same action more than once in the same job, the name will include a suffix with the sequence number with underscore before it. For example, the first script you run will have the name __run, and the second script will be named __run_2. 同様に、actions/checkoutの2回目の呼び出しはactionscheckout2となります。
github.action_pathstringThe path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action.
github.action_refstringFor a step executing an action, this is the ref of the action being executed. For example, v2.
github.action_repositorystringFor a step executing an action, this is the owner and repository name of the action. For example, actions/checkout.
github.action_statusstringFor a composite action, the current result of the composite action.
github.actorstringThe username of the user that initiated the workflow run.
github.api_urlstringThe URL of the GitHub REST API.
github.base_refstringワークフローの実行における base_ref またはPull Requestのターゲットブランチ。 このプロパティは、ワークフローの実行をトリガーするイベントが pull_request または pull_request_target のいずれかである� �合にのみ使用できます。
github.envstringPath on the runner to the file that sets environment variables from workflow commands. This file is unique to the current step and is a different file for each step in a job. 詳しい情� �については「GitHub Actionsのワークフローコマンド」を参照してく� さい。
github.eventオブジェクトwebhook ペイロードの完全なイベント。 このコンテキストを使用して、イベントの個々のプロパティにアクセスできます。 This object is identical to the webhook payload of the event that triggered the workflow run, and is different for each event. The webhooks for each GitHub Actions event is linked in "Events that trigger workflows." For example, for a workflow run triggered by the push event, this object contains the contents of the push webhook payload.
github.event_namestringワークフローの実行をトリガーしたイベントの名前。
github.event_pathstringThe path to the file on the runner that contains the full event webhook payload.
github.graphql_urlstringThe URL of the GitHub GraphQL API.
github.head_refstringワークフローの実行における head_ref またはPull Requestのソースブランチ。 このプロパティは、ワークフローの実行をトリガーするイベントが pull_request または pull_request_target のいずれかである� �合にのみ使用できます。
github.jobstring現在のジョブのjob_id
Note: This context property is set by the Actions runner, and is only available within the execution steps of a job. Otherwise, the value of this property will be null.
github.refstringワークフローの実行をトリガーしたブランチまたはタグ ref。 For workflows triggered by push, this is the branch or tag ref that was pushed. For workflows triggered by pull_request, this is the pull request merge branch. For workflows triggered by release, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format is refs/heads/<branch_name>, for pull requests it is refs/pull/<pr_number>/merge, and for tags it is refs/tags/<tag_name>. たとえば、refs/heads/feature-branch-1です。
github.pathstringPath on the runner to the file that sets system PATH variables from workflow commands. This file is unique to the current step and is a different file for each step in a job. 詳しい情� �については「GitHub Actionsのワークフローコマンド」を参照してく� さい。
github.server_urlstringThe URL of the GitHub server. たとえば、https://github.com などです。

Example contents of the github context

The following example context is from a workflow run triggered by the push event. The event object in this example has been truncated because it is identical to the contents of the push webhook payload.

Note: This context is an example only. The contents of a context depends on the workflow that you are running. Contexts, objects, and properties will vary significantly under different workflow run conditions.

{
  "token": "***",
  "job": "dump_contexts_to_log",
  "ref": "refs/heads/my_branch",
  "sha": "c27d339ee6075c1f744c5d4b200f7901aad2c369",
  "repository": "octocat/hello-world",
  "repository_owner": "octocat",
  "repositoryUrl": "git://github.com/octocat/hello-world.git",
  "run_id": "1536140711",
  "run_number": "314",
  "retention_days": "90",
  "run_attempt": "1",
  "actor": "octocat",
  "workflow": "Context testing",
  "head_ref": "",
  "base_ref": "",
  "event_name": "push",
  "event": {
    ...
  },
  "server_url": "https://github.com",
  "api_url": "https://api.github.com",
  "graphql_url": "https://api.github.com/graphql",
  "ref_name": "my_branch",
  "ref_protected": false,
  "ref_type": "branch",
  "secret_source": "Actions",
  "workspace": "/home/runner/work/hello-world/hello-world",
  "action": "github_step",
  "event_path": "/home/runner/work/_temp/_github_workflow/event.json",
  "action_repository": "",
  "action_ref": "",
  "path": "/home/runner/work/_temp/_runner_file_commands/add_path_b037e7b5-1c88-48e2-bf78-eaaab5e02602",
  "env": "/home/runner/work/_temp/_runner_file_commands/set_env_b037e7b5-1c88-48e2-bf78-eaaab5e02602"
}

Example usage of the github context

This example workflow uses the github.event_name context to run a job only if the workflow run was triggered by the pull_request event.

YAML
name: Run CI
on: [push, pull_request]

jobs:
  normal_ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Run normal CI
        run: ./run-tests

  pull_request_ci:
    runs-on: ubuntu-latest
    if: ${{ github.event_name == 'pull_request' }}
    steps:
      - uses: actions/checkout@v2
      - name: Run PR CI
        run: ./run-additional-pr-ci

envコンテキスト

envコンテキストには、ワークフロー、ジョブ、ステップで設定された環境変数が含まれます。 ワークフローでの環境変数の設定に関する詳しい情� �については「GitHub Actionsのワークフロー構文」を参照してく� さい。

envの構文で、ワークフローファイル中の環境変数の値を利用できます。 You can use the env context in the value of any key in a step except for the id and uses keys. ステップの構文に関する詳しい情� �については「GitHub Actionsのワークフロー構文」を参照してく� さい。

ランナー中で環境変数の値を使いたい� �合は、ランナーのオペレーティングシステ� で環境変数を読み取る通常の方法を使ってく� さい。

プロパティ名種類説明
envオブジェクトこのコンテキストは、ジョブのステップごとに異なります。 このコンテキストには、ジョブのあらゆるステップからアクセスできます。 This object contains the properties listed below.
env.<env_name>string特定の環境変数の値。

Example contents of the env context

The contents of the env context is a mapping of environment variable names to their values. The context's contents can change depending on where it is used in the workflow run.

{
  "first_name": "Mona",
  "super_duper_var": "totally_awesome"
}

Example usage of the env context

This example workflow shows how the env context can be configured at the workflow, job, and step levels, as well as using the context in steps.

同じ名前で複数の環境変数が定義されている� �合、GitHubは最も具体的な環境変数を使用します。 たとえば、ステップ中で定義された環境変数は、ジョブやワークフローの同じ名前の変数をステップの実行の間オーバーライドします。 ジョブで定義された変数は、そのジョブの実行の間はワークフローで定義された同じ名前の変数をオーバーライドします。

YAML
name: Hi Mascot
on: push
env:
  mascot: Mona
  super_duper_var: totally_awesome

jobs:
  windows_job:
    runs-on: windows-latest
    steps:
      - run: echo 'Hi ${{ env.mascot }}'  # Hi Mona
      - run: echo 'Hi ${{ env.mascot }}'  # Hi Octocat
        env:
          mascot: Octocat
  linux_job:
    runs-on: ubuntu-latest
    env:
      mascot: Tux
    steps:
      - run: echo 'Hi ${{ env.mascot }}'  # Hi Tux

job コンテキスト

job コンテキストは、現在実行中のジョブに関する情� �を含みます。

プロパティ名種類説明
ジョブオブジェクトこのコンテキストは、実行しているジョブごとに異なります。 このコンテキストには、ジョブのあらゆるステップからアクセスできます。 This object contains all the properties listed below.
job.containerオブジェクトジョブのコンテナに関する情� �。 コンテナに関する詳しい情� �については、「GitHub Actions のワークフロー構文」を参照してく� さい。
job.container.idstringThe ID of the container.
job.container.networkstringThe ID of the container network. runner は、コンテナ内のすべてのジョブに使用されるネットワークを作成します。
job.servicesオブジェクトジョブのために作成されたサービスコンテナ。 サービスコンテナに関する詳しい情� �については、「GitHub Actions のワークフロー構文」を参照してく� さい。
job.services.<service_id>.idstringThe ID of the service container.
job.services.<service_id>.networkstringThe ID of the service container network. runner は、コンテナ内のすべてのジョブに使用されるネットワークを作成します。
job.services.<service_id>.portsオブジェクトサービスコンテナの公開ポート。
job.statusstringジョブの現在の状態。 successfailurecancelled のいずれかの値をとります。

Example contents of the job context

This example job context uses a PostgreSQL service container with mapped ports. If there are no containers or service containers used in a job, the job context only contains the status property.

{
  "status": "success",
  "container": {
    "network": "github_network_53269bd575974817b43f4733536b200c"
  },
  "services": {
    "postgres": {
      "id": "60972d9aa486605e66b0dad4abb638dc3d9116f566579e418166eedb8abb9105",
      "ports": {
        "5432": "49153"
      },
      "network": "github_network_53269bd575974817b43f4733536b200c"
    }
  }
}

Example usage of the job context

This example workflow configures a PostgreSQL service container, and automatically maps port 5432 in the service container to a randomly chosen available port on the host. The job context is used to access the number of the port that was assigned on the host.

YAML
name: PostgreSQL Service Example
on: push
jobs:
  postgres-job:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres
        env:
          POSTGRES_PASSWORD: postgres
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
        ports:
          # Maps TCP port 5432 in the service container to a randomly chosen available port on the host.
          - 5432

    steps:
      - uses: actions/checkout@v2
      - run: pg_isready -h localhost -p ${{ job.services.postgres.ports[5432] }}
      - run: ./run-tests

steps コンテキスト

The steps context contains information about the steps in the current job that have an id specified and have already run.

プロパティ名種類説明
stepsオブジェクトこのコンテキストは、ジョブのステップごとに異なります。 このコンテキストには、ジョブのあらゆるステップからアクセスできます。 This object contains all the properties listed below.
steps.<step_id>.outputsオブジェクトステップに定義された出力のセット。 詳しい情� �については、「GitHub Actions のメタデータ構文」を参照してく� さい。
steps.<step_id>.conclusionstringcontinue-on-errorが適用された後に完了したステップの結果。 successfailurecancelledskippedのいずれかの値をとります。 continue-on-errorのステップが失敗すると、outcomefailureになりますが、最終的なconclusionsuccessになります。
steps.<step_id>.outcomestringcontinue-on-errorが適用される前の完了したステップの結果。 successfailurecancelledskippedのいずれかの値をとります。 continue-on-errorのステップが失敗すると、outcomefailureになりますが、最終的なconclusionsuccessになります。
steps.<step_id>.outputs.<output_name>string特定の出力の値。

Example contents of the steps context

This example steps context shows two previous steps that had an id specified. The first step had the id named checkout, the second generate_number. The generate_number step had an output named random_number.

{
  "checkout": {
    "outputs": {},
    "outcome": "success",
    "conclusion": "success"
  },
  "generate_number": {
    "outputs": {
      "random_number": "1"
    },
    "outcome": "success",
    "conclusion": "success"
  }
}

Example usage of the steps context

This example workflow generates a random number as an output in one step, and a later step uses the steps context to read the value of that output.

YAML
name: Generate random failure
on: push
jobs:
  randomly-failing-job:
    runs-on: ubuntu-latest
    steps:
      - id: checkout
        uses: actions/checkout@v2
      - name: Generate 0 or 1
        id: generate_number
        run:  echo "::set-output name=random_number::$(($RANDOM % 2))"
      - name: Pass or fail
        run: |
          if [[ ${{ steps.generate_number.outputs.random_number }} == 0 ]]; then exit 0; else exit 1; fi

runnerコンテキスト

runnerコンテキストには、現在のジョブを実行しているランナーに関する情� �が含まれています。

プロパティ名種類説明
runnerオブジェクトこのコンテキストは、実行しているジョブごとに異なります。 This object contains all the properties listed below.
runner.namestringThe name of the runner executing the job.
runner.osstringジョブを実行しているランナーのオペレーティングシステ� 。 取り得る値はLinuxWindowsmacOSのいずれか。
runner.tempstringランナー上の一時ディレクトリへのパス。 このディレクトリは、各ジョブの開始及び終了時点で空になります。 ランナーのユーザアカウントが削除する権限を持っていない� �合、ファイルは削除されないことに注意してく� さい。
runner.tool_cachestringGitHubホストランナーにプレインストールされているツールを含むディレクトリへのパス。 For more information, see "About GitHub-hosted runners".

Example contents of the runner context

The following example context is from a Linux GitHub-hosted runner.

{
  "os": "Linux",
  "arch": "X64",
  "name": "GitHub Actions 2",
  "tool_cache": "/opt/hostedtoolcache",
  "temp": "/home/runner/work/_temp"
}

Example usage of the runner context

This example workflow uses the runner context to set the path to the temporary directory to write logs, and if the workflow fails, it uploads those logs as artifact.

YAML
name: Build
on: push

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Build with logs
        run: |
          mkdir ${{ runner.temp }}/build_logs
          ./build.sh --log-path ${{ runner.temp }}/build_logs
      - name: Upload logs on fail
        if: ${{ failure() }}
        uses: actions/upload-artifact@v2
        with:
          name: Build failure logs
          path: ${{ runner.temp }}/build_logs

secrets context

The secrets context contains the names and values of secrets that are available to a workflow run. The secrets context is not available for composite actions. シークレットに関する詳しい情� �については「暗号化されたシークレット」を参照してく� さい。

GITHUB_TOKEN is a secret that is automatically created for every workflow run, and is always included in the secrets context. 詳しい情� �については「自動トークン認証」を参照してく� さい。

警告: GitHubは、ログに出力されたシークレットを自動的に削除しますが、シークレットをログに出力することは意識的に避けなくてはなりません。

プロパティ名種類説明
secretsオブジェクトThis context is the same for each job in a workflow run. このコンテキストには、ジョブのあらゆるステップからアクセスできます。 This object contains all the properties listed below.
secrets.GITHUB_TOKENstringAutomatically created token for each workflow run. 詳しい情� �については「自動トークン認証」を参照してく� さい。
secrets.<secret_name>stringThe value of a specific secret.

Example contents of the secrets context

The following example contents of the secrets context shows the automatic GITHUB_TOKEN, as well as two other secrets available to the workflow run.

{
  "github_token": "***",
  "NPM_TOKEN": "***",
  "SUPERSECRET": "***"
}

Example usage of the secrets context

以下のワークフローの例ではlabeler actionを使用しています。これには、repo-token入力パラメータの値としてGITHUB_TOKENを渡すことが必要です。

YAML
name: Pull request labeler
on: [ pull_request_target ]

jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/labeler@v3
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

strategy context

For workflows with a matrix, the strategy context contains information about the matrix execution strategy for the current job.

プロパティ名種類説明
strategyオブジェクトこのコンテキストは、実行しているジョブごとに異なります。 You can access this context from any job or step in a workflow. This object contains all the properties listed below.
strategy.fail-faststringWhen true, all in-progress jobs are canceled if any job in a matrix fails. 詳細については、「GitHub Actionsのワークフロー構文」を参照してく� さい。
strategy.job-indexstringThe index of the current job in the matrix. Note: This number is a zero-based number. The first job's index in the matrix is 0.
strategy.job-totalstringThe total number of jobs in the matrix. Note: This number is not a zero-based number. For example, for a matrix with four jobs, the value of job-total is 4.
strategy.max-parallelstringmatrixジョブ戦略を使用するとき、同時に実行できるジョブの最大数。 詳細については、「GitHub Actionsのワークフロー構文」を参照してく� さい。

Example contents of the strategy context

The following example contents of the strategy context is from a matrix with four jobs, and is taken from the final job. Note the difference between the zero-based job-index number, and job-total which is not zero-based.

{
  "fail-fast": true,
  "job-index": 3,
  "job-total": 4,
  "max-parallel": 4
}

Example usage of the strategy context

This example workflow uses the strategy.job-index property to set a unique name for a log file for each job in a matrix.

YAML
name: Test matrix
on: push

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        test-group: [1, 2]
        node: [14, 16]
    steps:
      - uses: actions/checkout@v2
      - run: npm test > test-job-${{ strategy.job-index }}.txt
      - name: Upload logs
        uses: actions/upload-artifact@v2
        with:
          name: Build log for job ${{ strategy.job-index }}
          path: test-job-${{ strategy.job-index }}.txt

matrix context

For workflows with a matrix, the matrix context contains the matrix properties defined in the workflow file that apply to the current job. For example, if you configure a matrix with the os and node keys, the matrix context object includes the os and node properties with the values that are being used for the current job.

There are no standard properties in the matrix context, only those which are defined in the workflow file.

プロパティ名種類説明
matrixオブジェクトThis context is only available for jobs in a matrix, and changes for each job in a workflow run. You can access this context from any job or step in a workflow. This object contains the properties listed below.
matrix.<property_name>stringThe value of a matrix property.

Example contents of the matrix context

The following example contents of the matrix context is from a job in a matrix that has the os and node matrix properties defined in the workflow. The job is executing the matrix combination of an ubuntu-latest OS and Node.js version 16.

{
  "os": "ubuntu-latest",
  "node": 16
}

Example usage of the matrix context

This example workflow creates a matrix with os and node keys. It uses the matrix.os property to set the runner type for each job, and uses the matrix.node property to set the Node.js version for each job.

YAML
name: Test matrix
on: push

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
        node: [14, 16]
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node }}
      - name: Install dependencies
        run: npm ci
      - name: Run tests
        run: npm test

needsコンテキスト

needsコンテキストは、現在のジョブの依存関係として定義されたすべてのジョブからの出力を含みます。 ジョブの依存関係の定義に関する詳しい情� �については「GitHub Actionsのワークフロー構文」を参照してく� さい。

プロパティ名種類説明
needsオブジェクトThis context is only populated for workflow runs that have dependent jobs, and changes for each job in a workflow run. You can access this context from any job or step in a workflow. This object contains all the properties listed below.
needs.<job_id>オブジェクト現在のジョブが依存している1つのジョブ。
needs.<job_id>.outputsオブジェクト現在のジョブが依存しているジョブの出力の集合。
needs.<job_id>.outputs.<output name>string現在のジョブが依存しているジョブの特定の出力の値。
needs.<job_id>.resultstring現在のジョブが依存しているジョブの結果。 successfailurecancelledskippedのいずれかの値をとります。

Example contents of the needs context

The following example contents of the needs context shows information for two jobs that the current job depends on.

{
  "build": {
    "result": "success",
    "outputs": {
      "build_id": "ABC123"
    }
  },
  "deploy": {
    "result": "failure",
    "outputs": {}
  }
}

Example usage of the needs context

This example workflow has three jobs: a build job that does a build, a deploy job that requires the build job, and a debug job that requires both the build and deploy jobs and runs only if there is a failure in the workflow. The deploy job also uses the needs context to access an output from the build job.

YAML
name: Build and deploy
on: push

jobs:
  build:
    runs-on: ubuntu-latest
    outputs:
      build_id: ${{ steps.build_step.outputs.build_id }}
    steps:
      - uses: actions/checkout@v2
      - name: Build
        id: build_step
        run: |
          ./build
          echo "::set-output name=build_id::$BUILD_ID" 
  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: ./deploy --build ${{ needs.build.outputs.build_id }}
  debug:
    needs: [build, deploy]
    runs-on: ubuntu-latest
    if: ${{ failure() }}
    steps:
      - uses: actions/checkout@v2
      - run: ./debug