ビジネスで GitHub Copilot 展開する場合は、 Copilot ライセンスを使用しているユーザーを追跡することが重要です。そのため、未使用のライセンスを再割り当てしたり、ユーザーが Copilotを使い始めたりして効果的に対応できます。
organization のすべての Copilot シート割り当てを一覧表示する API エンドポイントを使って、organization 内でライセンスが割り当てられている各ユーザーの最終アクティビティの日付を確認できます。 次に、一定期間ライセンスを使っていないユーザーをフィルター処理し、それらのユーザーにリマインダーを送信することで、自動的に応答できます。
リマインダー メッセージを書く
非アクティブなユーザーに対するリマインダーは、ユーザーが Copilotの一般的な導入の阻害要因を乗り越えるのに役立ちます。 アンケートを実施する、開発者に聞き取りするなどして、会社にとっての具体的な阻害要因を特定することをお勧めします。
たとえば、メッセージには、ユーザーに役立つ情報やリンクが含めることができます。
- 環境に Copilot をインストールします。
- 会社のプロキシまたはファイアウォールと連携するように Copilot を設定します。
- 日々の作業で Copilot を最大限に活用します。
また、ライセンスが未使用のままである場合は、ユーザーのライセンスを取り消すなど、追加の措置をとる予定であることも明確に伝えてください。
リマインダーの例
次のセクションでは、個々の非アクティブ ユーザーに割り当てられる issue を作成するオートメーションで使われているメッセージを紹介します。
GitHub Copilot に割り当てられたライセンスが 30 日間使用されていないことを確認しております。 こちらは、開始する際に役立つリソースです。
- 環境内で Copilot をまだ設定していない場合は、「 自分でGitHub Copilotを設定する 」または 「AUTOTITLE」を参照してください。
- 手始めのベストプラクティスやアドバイスについては、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 のリマインダー例に記載されているリマインダー メッセージなど、リマインダー メッセージをリポジトリまたは組織のGitHub Actions変数として保存します。
COPILOT_REMINDER_MESSAGEという変数にします。変数を作成するには、「変数に情報を格納する」を参照してください。
-
組織のすべての Copilot シート割り当てを一覧表示 API エンドポイントを呼び出す権限を持つ personal access token を作成します。 たとえば、次の詳細を指定して、きめ細かいトークンを作成します。
- リソース所有者: 非アクティブユーザーを探している組織。
- 組織のアクセス許可: 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 }}