GitHub Copilot をビジネスで展開する際には、Copilot ライセンスを使用しているユーザーを追跡することが重要です。これにより、未使用のライセンスを再割り当てしたり、Copilot の利用を開始する際にユーザーをサポートしたりして、効果的に対処できます。
[organization のすべての Copilot シート割り当てを一覧表示する](/rest/copilot/copilot-user-management#list-all-copilot-seat-assignments-for-an-organization) API エンドポイントを使って、organization 内でライセンスが割り当てられている各ユーザーの最終アクティビティの日付を確認できます。 次に、一定期間ライセンスを使っていないユーザーをフィルター処理し、それらのユーザーにリマインダーを送信することで、自動的に応答できます。
リマインダー メッセージを書く
非アクティブなユーザーに対するリマインダーは、ユーザーが Copilot の一般的な導入阻害要因を克服するのに役立ちます。 アンケートを実施する、開発者に聞き取りするなどして、会社にとっての具体的な阻害要因を特定することをお勧めします。
たとえば、メッセージには、ユーザーに役立つ情報やリンクが含めることができます。
- Copilot を環境にインストールします。
- 会社のプロキシまたはファイアウォールと連携できるように、Copilot を設定します。
- 日常業務で Copilot を最大限に活用しましょう。
また、ライセンスが未使用のままである場合は、ユーザーのライセンスを取り消すなど、追加の措置をとる予定であることも明確に伝えてください。
リマインダーの例
次のセクションでは、個々の非アクティブ ユーザーに割り当てられる issue を作成するオートメーションで使われているメッセージを紹介します。
お客様には GitHub Copilot のライセンスが割り当てられていますが、30 日間使われていません。 こちらは、開始する際に役立つリソースです。
- 環境内で Copilot をまだ設定していない場合は、自分でGitHub Copilot を設定する または GitHub Copilot に関する一般的な問題のトラブルシューティング を参照してください。
- 手始めのベストプラクティスやアドバイスについては、GitHub Copilot の使用に関するベスト プラクティス または GitHub Copilot Chat のプロンプト エンジニアリング をご覧ください。
- 特定のタスクに関連する例については、GitHub Copilot チャットクックブック を参照してください。
Copilot へのアクセスが必要なくなった場合は、この問題にてお知らせください。 ライセンスがさらに 30 日間非アクティブなままである場合は、別のユーザーのaccessを解放するためにライセンスを取り消します。
Markdown でのリマインダーの例
We noticed you haven't used your assigned license for GitHub Copilot in 30 days. Here are some resources that might help you get started: * If you haven't yet set up Copilot in your environment, see [Setting up GitHub Copilot for yourself](https://docs.github.com/en/copilot/setting-up-github-copilot/setting-up-github-copilot-for-yourself) or [Troubleshooting common issues with GitHub Copilot](https://docs.github.com/en/copilot/troubleshooting-github-copilot/troubleshooting-common-issues-with-github-copilot). * For best practices and advice on getting started, see [Best practices for using GitHub Copilot](https://docs.github.com/en/copilot/using-github-copilot/best-practices-for-using-github-copilot) or [Prompt engineering for GitHub Copilot](https://docs.github.com/en/copilot/using-github-copilot/prompt-engineering-for-github-copilot). * For examples related to specific tasks, see [Copilot Chat Cookbook](https://docs.github.com/en/copilot/example-prompts-for-github-copilot-chat). If you no longer need access to Copilot, please let us know in this issue. If your license remains inactive for a further 30 days, we'll revoke it to free up access for another user.
We noticed you haven't used your assigned license for GitHub Copilot in 30 days. Here are some resources that might help you get started:
* If you haven't yet set up Copilot in your environment, see [Setting up GitHub Copilot for yourself](https://docs.github.com/en/copilot/setting-up-github-copilot/setting-up-github-copilot-for-yourself) or [Troubleshooting common issues with GitHub Copilot](https://docs.github.com/en/copilot/troubleshooting-github-copilot/troubleshooting-common-issues-with-github-copilot).
* For best practices and advice on getting started, see [Best practices for using GitHub Copilot](https://docs.github.com/en/copilot/using-github-copilot/best-practices-for-using-github-copilot) or [Prompt engineering for GitHub Copilot](https://docs.github.com/en/copilot/using-github-copilot/prompt-engineering-for-github-copilot).
* For examples related to specific tasks, see [Copilot Chat Cookbook](https://docs.github.com/en/copilot/example-prompts-for-github-copilot-chat).
If you no longer need access to Copilot, please let us know in this issue. If your license remains inactive for a further 30 days, we'll revoke it to free up access for another user.
GitHub Actions を使ってリマインダーを自動化する
次のワークフロー例では、API を使って、organization 内で 30 日間ライセンスを使っていないユーザー、またはシートが割り当てられてからまったく使っていないユーザーを特定し、各ユーザーに割り当てられる issue を作成します。 これは、ニーズに合わせて調整できる簡単な例です。
このワークフローを使うには:
-
リマインダーの issue が作成されるリポジトリにラベルを作成します。
copilot-reminderというラベルにします。 このラベルを使って、個々の非アクティブ ユーザーに対してリマインダーの issue が既に開かれているかどうかをチェックします。ラベルを作成するには、「ラベルを管理する」を参照してください。
-
「Markdown でのリマインダーの例」に記載されているようなリマインダー メッセージを、リポジトリまたは organization の GitHub Actions 変数として保存します。
COPILOT_REMINDER_MESSAGEという変数にします。変数を作成するには、「変数に情報を格納する」を参照してください。
-
personal access token に 組織のすべての Copilot シート割り当てを一覧表示する API エンドポイントを呼び出す権限を付与して作成します。 たとえば、次の詳細を指定して、きめ細かいトークンを作成します。 * リソース所有者: 非アクティブユーザーを探している組織。 * Organization のアクセス許可: GitHub Copilot ビジネス (読み取り専用)。
トークンを作成するには、個人用アクセス トークンを管理する を参照してください。
-
アクセス トークンをリポジトリまたは組織のGitHub Actionsシークレットとして保存します。
COPILOT_LICENSE_READというシークレットにします。シークレットを作成するには、「GitHub Actions でのシークレットの使用」を参照してください。
-
以下の例を使って、リマインダーの issue を作成するワークフローをリポジトリに作成します。
GitHub Actions を初めて使う場合は、「GitHub Actionsのクイック スタート」を参照してください。
-
ワークフローが配置されているリポジトリ以外のリポジトリに問題を作成する場合は、
${{ github.repository }}コマンドのghを、アラームの問題を作成するリポジトリの名前に置き換えます。 (例:octo-org/octo-repo)。
ワークフローの例
メモ
この例では、organization を通じてライセンスを割り当てることを前提としています。 エンタープライズ アカウントとエンタープライズ チームにも同様の API エンドポイントが存在します。 「Copilotユーザー管理のためのREST APIエンドポイント」を参照してください。
# Name your workflow
name: Remind inactive users about GitHub Copilot license
on:
# Run on demand (enables `Run workflow` button on the Actions tab to easily trigger a run manually)
workflow_dispatch:
# Run the workflow every day at 8am UTC
schedule:
- cron: '0 8 * * *'
jobs:
context-log:
runs-on: ubuntu-latest
# Modify the default permissions granted to GITHUB_TOKEN
permissions:
contents: read
issues: write
steps:
- name: Check last GitHub Copilot activity
id: check-last-activity
run: |
# List all GitHub Copilot seat assignments for an organization
RESPONSE=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Authorization: Bearer ${{ secrets.COPILOT_LICENSE_READ }}" \
/orgs/${{ github.repository_owner }}/copilot/billing/seats)
echo "Raw Response from gh api:"
echo "$RESPONSE"
# Parse and check each user's `last_activity_at` and `created_at`
echo "$RESPONSE" | jq -c '.seats[]' | while read -r seat; do
LOGIN=$(echo "$seat" | jq -r '.assignee.login')
LAST_ACTIVITY=$(echo "$seat" | jq -r '.last_activity_at')
CREATED_AT=$(echo "$seat" | jq -r '.created_at')
# List all open issues with label `copilot-reminder`
EXISTING_ISSUES=$(gh issue list --repo ${{ github.repository }} --assignee $LOGIN --label 'copilot-reminder' --json id)
# Get last activity date and convert dates to seconds since epoch for comparison
if [ "$LAST_ACTIVITY" = "null" ]; then
LAST_ACTIVITY_DATE=$(date -d "$CREATED_AT" +%s)
else
LAST_ACTIVITY_DATE=$(date -d "$LAST_ACTIVITY" +%s)
fi
THIRTY_DAYS_AGO=$(date -d "30 days ago" +%s)
# Create issues for inactive users who don't have an existing open issue
if [ "$LAST_ACTIVITY_DATE" -lt "$THIRTY_DAYS_AGO" ] && [ "$EXISTING_ISSUES" = "[]" ]; then
echo "User $LOGIN has not been active in the last 30 days. Last activity: $LAST_ACTIVITY"
NEW_ISSUE_URL="$(gh issue create --title "Reminder about your GitHub Copilot license" --body "${{ vars.COPILOT_REMINDER_MESSAGE }}" --repo ${{ github.repository }} --assignee $LOGIN --label 'copilot-reminder')"
else
echo "User $LOGIN is active or already has an assigned reminder issue. Last activity: $LAST_ACTIVITY"
fi
done
# Set the GH_TOKEN, required for the 'gh issue' commands
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Remind inactive users about GitHub Copilot license
on:Name your workflow
workflow_dispatch:Run on demand (enables Run workflow button on the Actions tab to easily trigger a run manually)
schedule:
- cron: '0 8 * * *'
jobs:
context-log:
runs-on: ubuntu-latestRun the workflow every day at 8am UTC
permissions:
contents: read
issues: write
steps:
- name: Check last GitHub Copilot activity
id: check-last-activity
run: |Modify the default permissions granted to GITHUB_TOKEN
RESPONSE=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Authorization: Bearer ${{ secrets.COPILOT_LICENSE_READ }}" \
/orgs/${{ github.repository_owner }}/copilot/billing/seats)
echo "Raw Response from gh api:"
echo "$RESPONSE"List all GitHub Copilot seat assignments for an organization
echo "$RESPONSE" | jq -c '.seats[]' | while read -r seat; do
LOGIN=$(echo "$seat" | jq -r '.assignee.login')
LAST_ACTIVITY=$(echo "$seat" | jq -r '.last_activity_at')
CREATED_AT=$(echo "$seat" | jq -r '.created_at')Parse and check each user's last_activity_at and created_at
EXISTING_ISSUES=$(gh issue list --repo ${{ github.repository }} --assignee $LOGIN --label 'copilot-reminder' --json id)List all open issues with label copilot-reminder
if [ "$LAST_ACTIVITY" = "null" ]; then
LAST_ACTIVITY_DATE=$(date -d "$CREATED_AT" +%s)
else
LAST_ACTIVITY_DATE=$(date -d "$LAST_ACTIVITY" +%s)
fi
THIRTY_DAYS_AGO=$(date -d "30 days ago" +%s)Get last activity date and convert dates to seconds since epoch for comparison
if [ "$LAST_ACTIVITY_DATE" -lt "$THIRTY_DAYS_AGO" ] && [ "$EXISTING_ISSUES" = "[]" ]; then
echo "User $LOGIN has not been active in the last 30 days. Last activity: $LAST_ACTIVITY"
NEW_ISSUE_URL="$(gh issue create --title "Reminder about your GitHub Copilot license" --body "${{ vars.COPILOT_REMINDER_MESSAGE }}" --repo ${{ github.repository }} --assignee $LOGIN --label 'copilot-reminder')"
else
echo "User $LOGIN is active or already has an assigned reminder issue. Last activity: $LAST_ACTIVITY"
fi
doneCreate issues for inactive users who don't have an existing open issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}Set the GH_TOKEN, required for the 'gh issue' commands
# Name your workflow
name: Remind inactive users about GitHub Copilot license
on:
# Run on demand (enables `Run workflow` button on the Actions tab to easily trigger a run manually)
workflow_dispatch:
# Run the workflow every day at 8am UTC
schedule:
- cron: '0 8 * * *'
jobs:
context-log:
runs-on: ubuntu-latest
# Modify the default permissions granted to GITHUB_TOKEN
permissions:
contents: read
issues: write
steps:
- name: Check last GitHub Copilot activity
id: check-last-activity
run: |
# List all GitHub Copilot seat assignments for an organization
RESPONSE=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Authorization: Bearer ${{ secrets.COPILOT_LICENSE_READ }}" \
/orgs/${{ github.repository_owner }}/copilot/billing/seats)
echo "Raw Response from gh api:"
echo "$RESPONSE"
# Parse and check each user's `last_activity_at` and `created_at`
echo "$RESPONSE" | jq -c '.seats[]' | while read -r seat; do
LOGIN=$(echo "$seat" | jq -r '.assignee.login')
LAST_ACTIVITY=$(echo "$seat" | jq -r '.last_activity_at')
CREATED_AT=$(echo "$seat" | jq -r '.created_at')
# List all open issues with label `copilot-reminder`
EXISTING_ISSUES=$(gh issue list --repo ${{ github.repository }} --assignee $LOGIN --label 'copilot-reminder' --json id)
# Get last activity date and convert dates to seconds since epoch for comparison
if [ "$LAST_ACTIVITY" = "null" ]; then
LAST_ACTIVITY_DATE=$(date -d "$CREATED_AT" +%s)
else
LAST_ACTIVITY_DATE=$(date -d "$LAST_ACTIVITY" +%s)
fi
THIRTY_DAYS_AGO=$(date -d "30 days ago" +%s)
# Create issues for inactive users who don't have an existing open issue
if [ "$LAST_ACTIVITY_DATE" -lt "$THIRTY_DAYS_AGO" ] && [ "$EXISTING_ISSUES" = "[]" ]; then
echo "User $LOGIN has not been active in the last 30 days. Last activity: $LAST_ACTIVITY"
NEW_ISSUE_URL="$(gh issue create --title "Reminder about your GitHub Copilot license" --body "${{ vars.COPILOT_REMINDER_MESSAGE }}" --repo ${{ github.repository }} --assignee $LOGIN --label 'copilot-reminder')"
else
echo "User $LOGIN is active or already has an assigned reminder issue. Last activity: $LAST_ACTIVITY"
fi
done
# Set the GH_TOKEN, required for the 'gh issue' commands
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
参考資料
-
[AUTOTITLE](/copilot/reference/metrics-data#last_activity_at) -
[AUTOTITLE](/copilot/rolling-out-github-copilot-at-scale/driving-copilot-adoption-in-your-company) -
[AUTOTITLE](/copilot/rolling-out-github-copilot-at-scale/analyzing-usage-over-time-with-the-copilot-metrics-api)