> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/aikido-device-protection/deploying-aikido-endpoint/device-protection-mdm-guides/linux/device-protection-in-github-actions.md).

# GitHub Actions での Device Protection

GitHub Actions のジョブは Linux ランナー上で実行されるため、Device Protection は他の Linux マシンと同じ方法でインストールされます。GitHub Actions 特有なのは、インストール先です。つまり、常駐する self-hosted runner に 1 回インストールするか、ジョブ終了後に破棄される hosted runner の各ジョブ内でインストールするかです。

まず [Linux 用 Device Protection をインストールする](/docs/docs-ja/aikido-device-protection/deploying-aikido-endpoint/device-protection-mdm-guides/linux/install-device-protection-for-linux.md) トークンとインストール方式についてお読みください。以下のジョブレベルのスニペットでは container 方式を使用しており、これは [コンテナ内の Device Protection](/docs/docs-ja/aikido-device-protection/deploying-aikido-endpoint/device-protection-mdm-guides/linux/device-protection-in-containers.md) を説明しています。

## GitHub がホストするランナー

Device Protection トークンを、という名前のシークレットとして追加してください `AIKIDO_TOKEN`その後、パッケージをインストールするステップの前にエージェントを起動します:

{% code title=".github/workflows/build.yml" overflow="wrap" %}

```yaml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Device Protection を開始
        env:
          AIKIDO_TOKEN: ${{ secrets.AIKIDO_TOKEN }}
        run: |
          curl -fsSL https://github.com/AikidoSec/safe-chain/raw/refs/heads/main/install-scripts/install-endpoint-linux.sh \
            | sudo AIKIDO_TOKEN="$AIKIDO_TOKEN" sh -s -- --container
          sudo aikido-endpoint-protection-start --wait-for-healthy

      - uses: actions/checkout@v4

      - name: 依存関係をインストール
        run: |
          for f in /etc/profile.d/aikido-*.sh; do . "$f"; done
          npm ci
```

{% endcode %}

* **トークンはの後に渡します `sudo`.** `sudo` 残りの環境変数は失われます。
* **ソース `/etc/profile.d/aikido-*.sh` パッケージをインストールするすべてのステップで。** 各ステップは新しいシェルであり、それらの設定がないとダウンロード時にエージェントがスキップされます。
* **runner は VM ですが、 `--container`.** ジョブから runner を再起動することはできず、container モードでは再起動も不要です。そのため、エージェントは明示的に起動します。参照: [インストール方式を選択](/docs/docs-ja/aikido-device-protection/deploying-aikido-endpoint/device-protection-mdm-guides/linux/install-device-protection-for-linux.md#choose-the-install-flavor).

ソース行を省略するには、各ステップをログインシェルで実行します。ログインシェルは `/etc/profile.d/` 単独で:

{% code title=".github/workflows/build.yml" overflow="wrap" %}

```yaml
defaults:
  run:
    shell: bash --login -eo pipefail {0}
```

{% endcode %}

## ジョブコンテナ

〜を使用するジョブ `container:` root として実行されるので、同じ手順を、なしで使います `sudo`。イメージには必要です `curl`。イメージにすでにエージェントがインストールされている場合は、インストールを省略して起動のみ行ってください。参照: [GitHub Actions のジョブコンテナ](/docs/docs-ja/aikido-device-protection/deploying-aikido-endpoint/device-protection-mdm-guides/linux/device-protection-in-containers.md#job-containers-in-github-actions).

## self-hosted runner

runner ホストにエージェントを `--headless`付きでインストールし、その後再起動します。参照: [Linux 用 Device Protection をインストールする](/docs/docs-ja/aikido-device-protection/deploying-aikido-endpoint/device-protection-mdm-guides/linux/install-device-protection-for-linux.md#choose-the-install-flavor).

## 動作確認

{% code title=".github/workflows/build.yml" overflow="wrap" %}

```yaml
      - name: Device Protection を検証
        run: |
          for f in /etc/profile.d/aikido-*.sh; do . "$f"; done
          curl -sS -o /dev/null -w "%{http_code}\n" --max-time 15 https://registry.npmjs.org/safe-chain-test/-/safe-chain-test-0.0.1-security.tgz
```

{% endcode %}

`403` は、エージェントがマルウェアのテスト用パッケージをブロックしたことを意味します。 `200` は、ダウンロードがエージェントを回避したことを意味します。

## トラブルシューティング

| 問題                                                | 修正                                                                                                        |
| ------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `トークンが必要です`                                       | シークレットがインストール処理に渡りませんでした。次の下にマップしてください `env` そして、その後に渡してください `sudo`。フォークされた pull request にはシークレットが付与されません |
| `root 権限が必要です`                                    | インストールと開始コマンドの前に `sudo`                                                                                   |
| テストパッケージが返す `200`、または `SELF_SIGNED_CERT_IN_CHAIN` | そのステップでは source が読み込まれませんでした `/etc/profile.d/aikido-*.sh`                                                 |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.aikido.dev/docs/docs-ja/aikido-device-protection/deploying-aikido-endpoint/device-protection-mdm-guides/linux/device-protection-in-github-actions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
