Skip to main content

GITHUB_TOKEN

Learn what GITHUB_TOKEN is, how it works, and why it matters for secure automation in GitHub Actions workflows.

About the GITHUB_TOKEN

At the start of each workflow job, GitHub automatically creates a unique GITHUB_TOKEN secret to use in your workflow. You can use the GITHUB_TOKEN to authenticate in the workflow job.

When you enable GitHub Actions, GitHub installs a GitHub App on your repository. The GITHUB_TOKEN secret is a GitHub App installation access token. You can use the installation access token to authenticate on behalf of the GitHub App installed on your repository. The token's permissions are limited to the repository that contains your workflow. For more information, see GITHUB_TOKEN reference.

Before each job begins, GitHub fetches an installation access token for the job. ジョブが終了するか最大 24 時間後に、GITHUB_TOKEN の有効期限が切れます。

The token is also available in the github.token context. For more information, see Contexts reference.

When GITHUB_TOKEN triggers workflow runs

リポジトリの GITHUB_TOKEN を使ってタスクを実行した場合、GITHUB_TOKEN によってトリガーされたイベントでは (workflow_dispatchrepository_dispatch を除きます)、新しいワークフロー実行は作成されません。 これによって、予想外の再帰的なワークフローの実行が生じないようになります。 たとえば、ワークフロー実行でリポジトリの GITHUB_TOKEN を使用してコードがプッシュされた場合、push イベントの発生時に実行するように構成されたワークフローがリポジトリに含まれている場合でも、新しいワークフローは実行されません。

GITHUB_TOKEN を使う GitHub Actions ワークフローによってプッシュされたコミットでは、GitHub Pages ビルドがトリガーされません。

Next steps