> For the complete documentation index, see [llms.txt](https://manual.dxable.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.dxable.com/1password/load-secrets-from-1password-into-github-actions.md).

# 1Password のシークレットを GitHub Actions にロードする

[1Password GitHub Actionからシークレットをロード](https://github.com/marketplace/actions/load-secrets-from-1password)する、[シークレット参照](https://developer.1password.com/docs/cli/secret-reference-syntax)を使用して、1Password から GitHub Actions にシークレットを安全に読み込むことができます。シークレット参照は 1Password と自動的に同期され、コード内のプレーンテキストのシークレットが公開されるリスクがなくなります。

[1Password Connect Server](https://developer.1password.com/docs/connect/)または[1Password Service Account](https://developer.1password.com/docs/service-accounts/)load-secrets-actionを使用して認証できます。サービス アカウントで GitHub Action を使う方法の簡単な紹介については、以下のビデオをご覧ください。

<https://youtu.be/kVBl5iQYgSA>

INFO

通常の[GitHubリポジトリシークレット](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions)と同様, 1Password は、GitHub Actions ログに表示される機密フィールドを自動的にマスクします。これらの値のいずれかが誤って印刷された場合は、 \*\*\*に置き換えられます。

### **Requirements** <a href="#i4vckzvu4drs" id="i4vckzvu4drs"></a>

[サービス アカウント](https://developer.1password.com/docs/service-accounts/)または[Connect サーバーの](https://developer.1password.com/docs/connect/)いずれかを使用して 1Passwordに認証するアクションを構成できます。

**Service account**

[1Password GitHub Actionからシークレットをロード](https://github.com/marketplace/actions/load-secrets-from-1password)する前にサービス アカウントを使う場合は、次の操Createを行う必要があります。

* 1Passwordに[サインアップしてください。](https://start.1password.com/sign-up/plan)
* [サービス アカウントをCreateします。](https://developer.1password.com/docs/service-accounts/)
* サービス アカウント トークンを用意してください。

**Connect**

[1Password GitHub Actionからシークレットをロード](https://github.com/marketplace/actions/load-secrets-from-1password)する前にConnect サーバーを使う場合は、次の操Createを行う必要があります。

* 1Passwordに[サインアップしてください。](https://start.1password.com/sign-up/plan)
* インフラストラクチャ内に[Connect サーバーをCreateして展開します。](https://developer.1password.com/docs/connect/get-started/#step-2-deploy-1password-connect-server)
* Connect サーバーのホスト名と Connect サーバーのトークンを用意してください。

注意

[1Password GitHub Action からシークレットをロード](https://github.com/marketplace/actions/load-secrets-from-1password)する[MacとLinuxランナー](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners)のみサポートWindows ランナーでは動作しません。

### **Get started** <a href="#nh59m3ews1" id="nh59m3ews1"></a>

開始手順は、サービス アカウントを使うか Connect サーバーを使うかによって異なります。

**Service account**

* ①[1Password GitHub アクションからシークレットをロードする](https://github.com/marketplace/actions/load-secrets-from-1password)をワークフローに追加します。。\
  [ワークフローにアクションを追加する](https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions#adding-an-action-to-your-workflow)を参照してください。
* ②サービス アカウント トークンをワークフローに追加します。\
  OP\_SERVICE\_ACCOUNT\_TOKENという名前の GitHub リポジトリのシークレットをCreateし、それをサービス アカウント トークンの値に設定します。\
  [GitHub Actions でのシークレットの使用を](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions)ご覧ください方法を学ぶために。
* ③ワークフローを構成します。\
  1password/load-secrets-action/configureアクションを使用して、シークレットを取得する予定のサービス アカウントのトークンを指定します。\
  次の例では、コマンドを使用して、 service-account-token をOP\_SERVICE\_ACCOUNT\_TOKENシークレットにconfigure設定します。

![](/files/UeIRZdw3dlmm2LA10bmV)

ヒント

configureステップでservice-account-token を設定すると、その値が後続の全てのステップで使用できるようになります。

特定のステップでのみサービス アカウント トークンを使うことで、ステップのアクセスをサービス アカウント トークンに制限できます。

特定のステップでサービス アカウント トークンを使うには、そのステップのenv変数に設定します。

![](/files/90n8K690OxodGH9HOtCA)

④シークレットをロードします。

この1password/load-secrets-actionアクションを使用して、 1Password アカウント内のシークレットがSaveされている場所を指す[secret reference URI](https://developer.1password.com/docs/ci-cd/github-actions/?workflow-type=service-account#secret-reference-syntax) に環境変数を設定します。

次の例では、SECRET環境変数を、app-cicdというタイトルの保管庫にSaveされた hello-worldという項目内のsecretという名前のフィールドの値に設定します。

![](/files/ARL3q9RYSfCGBYBGrxoE)

* このアクションにより、参照されたシークレットがSECRET次のステップの環境変数として使用できるようになります。

### **Connect** <a href="#mtx73290jwjg" id="mtx73290jwjg"></a>

* ① [Load secrets from 1Password GitHub Action ](https://github.com/marketplace/actions/load-secrets-from-1password)(load-secrets-action) をワークフローに追加します。\
  [ワークフローにアクションを追加する](https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions#adding-an-action-to-your-workflow)を参照してください。
* ②Connect サーバー トークンをワークフローに追加します。\
  リポジトリにOP\_CONNECT\_TOKENという名前のシークレットをCreateし、それを Connect サーバー トークンの値に設定します。\
  [GitHub Actions でのシークレットの使用を](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions)ご覧ください方法を学ぶために。
* ③ワークフローを構成します。\
  1password/load-secrets-action/configureアクションを使用して、Connect server environment variableを指定します。\
  次の例では、configure コマンドを使用して次の操Createを実行します。
  * connect-host をConnect サーバーのホスト名 ( OP\_CONNECT\_HOST ) に設定します。
  * connect-tokenをOP\_CONNECT\_TOKENシークレットに設定します。

![](/files/XiBZyFCwDQ3vULUCwrWl)

ヒント

構成ステップでconnect-token を設定すると、その値が後続の全てのステップで使用できるようになります。特定のステップでのみサービス アカウント トークンを使うことで、サービス アカウント トークンへのステップ アクセスを制限できます。

特定のステップでサービス アカウント トークンを使うには、envそのステップの変数に設定します。

![](/files/BjEjPCTxps0dH0CKASpw)

④シークレットをロードします。

このアクションを使用して、 1Password アカウント内のシークレットがSaveされている場所を指す[シークレット参照 URI](https://developer.1password.com/docs/ci-cd/github-actions/?workflow-type=connect#secret-reference-syntax)1password/load-secrets-actionに環境変数を設定します。

次の例では、SECRET環境変数を、app-cicd という名前の保管庫にSaveされている hello-world という名前の項目内の Secret という名前のフィールドの値に設定します。

![](/files/orFR8lRqOvC3kyDHG4AL)

このアクションにより、参照されたシークレットがSECRET次のステップの環境変数として使用できるようになります。

### **Reference** <a href="#nezo3bx59nu2" id="nezo3bx59nu2"></a>

次のセクションでは、[1Password GitHub アクションからシークレットをロードする](https://github.com/marketplace/actions/load-secrets-from-1password)ための[アクション入力](https://developer.1password.com/docs/ci-cd/github-actions/?workflow-type=connect#action-inputs)と[シークレット参照構文について説明します。](https://developer.1password.com/docs/ci-cd/github-actions/?workflow-type=connect#secret-reference-syntax)

#### **Action inputs** <a href="#rtzca2lrkil3" id="rtzca2lrkil3"></a>

次の表に、使用可能なconfigureアクション入力を示します。

| **アクション入力**           | **環境変数**                    | **説明**                                   |
| --------------------- | --------------------------- | ---------------------------------------- |
| connect-host          | OP\_CONNECT\_HOST           | Connect サーバー、ホスト名、IP アドレス、またはインスタンス URL。 |
| connect-token         | OP\_CONNECT\_TOKEN          | Connect サーバー トークン。                       |
| service-account-token | OP\_SERVICE\_ACCOUNT\_TOKEN | サービス アカウント トークン。                         |

#### **Secret reference syntax** <a href="#b9xyzt8u8xgj" id="b9xyzt8u8xgj"></a>

シークレット参照 URI は、情報がSaveされている保管庫、アイテム、セクション、フィールドの名前を使用して、1Password アカウント内でシークレットがSaveされている場所を指します。

![](/files/NCnEAYlFgcrungJoztCF)

ワークフロー YAML ファイル内のシークレット参照に環境変数を設定すると、アクションによって、参照されたシークレットが次のステップの環境変数として使用できるようになります。

**Example**

次の例は、app-cicd 保管庫内の aws アイテムの Secret-access-key フィールドを参照する方法を示しています。

![](/files/SciTpMhgFTcsIidCIYyp)

![](/files/kM6Ius0wp2K18s2jpjhs)

### **Usage examples** <a href="#bo0z7k79ci3" id="bo0z7k79ci3"></a>

アクションを使用してシークレットをロードするには、次の 2 つの方法があります。

* ①[アクションの出力からシークレットを使う](https://developer.1password.com/docs/ci-cd/github-actions/?workflow-type=connect#use-secrets-from-the-actions-output)
* ②[シークレットを環境変数としてエクスポートする](https://developer.1password.com/docs/ci-cd/github-actions/?workflow-type=connect#export-secrets-as-environment-variables)

#### **Use secrets from the action's output** <a href="#pwtqdvtsbf4t" id="pwtqdvtsbf4t"></a>

[1Password GitHub Actionからシークレットを読み込む](https://github.com/marketplace/actions/load-secrets-from-1password)ことができます環境変数としてシークレットにアクセスします。

**Service account**

次の例は、サービス アカウントからシークレットを読み込み、pushイベントが発生したときに出力を印刷する方法を示しています。

ステップの出力にアクセスするには、ステップのIDを設定する必要があります。[outputs.\<output\_id> ](https://docs.github.com/actions/creating-actions/metadata-syntax-for-github-actions#outputsoutput_id)。

**Simple example**

次の例は、サービス アカウントを使用して 1Password からシークレット (SECRET 環境変数として) をロード (および出力) する方法を示しています。シークレットを印刷すると、1Password は自動的にそれを \*\*\* に置き換えます。

![](/files/9ILOwrtNaO8vEiCImAch)

The following example shows how to use a service account to load the username and token fields from the docker secret in 1Password (as DOCKERHUB\_USERNAME and DOCKERHUB\_TOKEN), then use them to log into Docker Hub.

次の例は、サービス アカウントを使用して 1Password の Docker シークレットからユーザー名とトークン フィールド (DOCKERHUB\_USERNAME および DOCKERHUB\_TOKEN として) を読み込み、それらを使用して Docker Hub にログインする方法を示しています。

config.yml

![](/files/poVMFv70thvQ6a7E1w8G)

**Connect**

次の例は、プッシュ イベントの発生時に Connect サーバーからシークレットをロードし、出力を印刷する方法を示しています。

**Simple example**

次の例は、Connect サーバーを使用して 1Password からシークレット (SECRET 環境変数として) をロード (および出力) する方法を示しています。シークレットを印刷すると、1Password は自動的にそれを \*\*\* に置き換えます。

![](/files/NwUKZCtvHPYX3J5nvNqX)

**Advanced example**

次の例は、Connect サーバーを使用して 1Password の Docker シークレットからユーザー名とトークン フィールド (DOCKERHUB\_USERNAME および DOCKERHUB\_TOKEN として) をロードし、それらを使用して Docker Hub にログインする方法を示しています。

config.yml

![](/files/wLBthgA56oQCiEPCj2Od)

#### **Export secrets as environment variables** <a href="#mfq28z6f7i32" id="mfq28z6f7i32"></a>

「1Password GitHub からシークレットをロード」アクションを使用して、steps.step-id.outputs.secret-name から出力されたロードされたシークレットを使用できます。

**Service account**

次の例は、サービス アカウントを使用して 1Password シークレットを環境変数としてロードする方法を示しています。

**Simple example**

次の例は、サービス アカウントを使用して、SECRET という名前の環境変数としてシークレットをロードする方法を示しています。シークレットを印刷すると、1Password は自動的にそれを \*\*\* に置き換えます。

![](/files/FH9UCYwvlBsYMQuTKl4L)

**Advanced example**

次の例は、サービス アカウントを使用して、1Password の Docker シークレットからユーザー名とトークン フィールドを DOCKERHUB\_USERNAME および DOCKERHUB\_TOKEN という名前の環境変数としてロードし、それらを使用して Docker Hub にログインする方法を示しています。

また、1Password の aws シークレットから access-key-id フィールドと Secret-access-key フィールドを AWS\_ACCESS\_KEY\_ID および AWS\_SECRET\_ACCESS\_KEY という名前の環境変数としてロードし、それらを使用して AWS にデプロイします。

config.yml

![](/files/aw8Vck372CrVyxQ0vv8q)

**Connect**

次の例は、Connect サーバーを使用して 1Password からシークレットを環境変数としてロードする方法を示しています。

**Simple example**

次の例は、Connect サーバーを使用して、SECRET という名前の環境変数としてシークレットをロードする方法を示しています。シークレットを印刷すると、1Password は自動的にそれを \*\*\* に置き換えます。

config.yml\
![](/files/htIER14viKJDaKWZGVoS)

**Advanced example**

次の例は、Connect サーバーを使用して 1Password の Docker シークレットからユーザー名とトークン フィールドを DOCKERHUB\_USERNAME および DOCKERHUB\_TOKEN という名前の環境変数としてロードし、それらを使用して Docker Hub にログインする方法を示しています。

また、1Password の aws シークレットから access-key-id フィールドと Secret-access-key フィールドを AWS\_ACCESS\_KEY\_ID および AWS\_SECRET\_ACCESS\_KEY という名前の環境変数としてロードし、それらを使用して AWS にデプロイします。

config.yml

![](/files/yRcK4OKi1bSnRzp6ejXI)

### **Troubleshooting** <a href="#ndls4noxk0gm" id="ndls4noxk0gm"></a>

GitHub パイプラインで 1Password CLI を使用して (load-secrets-action を使用せずに) アイテムをCreateしようとすると、コマンドは次のエラーで失敗します。

Failed to create item: invalid JSON

例えば、次の場合はエラーが発生します。

![](/files/zIjYWnaGr4wQyXg79uEe)

パイプライン環境はパイプ モードです。これにより、パイプ入力を期待する CLI のパイプ検出がトリガーされます。

この環境でアイテムをCreateするには、アイテムの詳細を含む[JSON テンプレートを使用します。](https://developer.1password.com/docs/cli/item-template-json/)

* ①Createしたいアイテムのカテゴリのテンプレートを取得します。
* $ op item template get --out-file=new-item.json \<category>
* ②[テンプレートを](https://developer.1password.com/docs/cli/item-template-json/)編集して情報を追加します。
* ③アイテムの内容をコマンドにパイプします。
* $ cat new-item.json | op item create --vault \<vault>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.dxable.com/1password/load-secrets-from-1password-into-github-actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
