在企业中推出 GitHub Copilot 时,请务必跟踪哪些用户使用其 Copilot 许可证,以便你通过重新分配未使用的许可证或帮助用户开始使用 Copilot 来有效响应。
可以使用列出组织的所有 Copilot 席位分配 API 终结点来查找组织中分配有许可证的每个用户的最后活动日期。 然后,可以通过筛选一定时间内未使用其许可证的用户并向这些用户发送提醒来自动做出响应。
编写提醒消息
你对非活动用户的提醒应帮助用户克服常见的 Copilot 采用障碍。 建议通过开展调查或采访开发人员来识别公司的特定阻碍因素。
例如,该消息可以包含帮助用户的信息和链接:
- 在环境中安装 Copilot。
- 将 Copilot 设置为使用公司的代理或防火墙。
- 在日常工作中充分利用 Copilot。
你还应明确传达在许可证仍不被使用的情况下你将采取的任何进一步的行动,例如撤销用户的许可证。
提醒示例
在下一部分中,我们将在自动化中使用此消息,创建分配给每个非活动用户的议题。
我们注意到您在 30 天内未使用过分配的 GitHub Copilot 许可证。 以下是一些可帮助您入门的资源和应用:
- 如果您尚未在环境中设置 Copilot,请参阅“为自己设置 GitHub Copilot”或“排查 GitHub Copilot 的常见问题”。
- 有关入门的最佳做法和建议,请参阅“有关使用 GitHub Copilot 的最佳做法”或“Copilot Chat 的提示设计”。
- 有关特定任务的相关示例,请参阅“Copilot 聊天指南”。
如果不再需要访问 Copilot,请在此议题中告知我们。 如果您的许可证在未来 30 天内仍处于非活动状态,我们将撤销该许可证来释放访问权限,以供其他用户使用。
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 识别组织中 30 天内未使用过其许可证的用户,然后创建分配给每个用户的议题。 这是一个简单的示例,你可以对其进行调整来满足你的需求。
此工作流可用于:
-
在将创建提醒议题的仓库中创建标签。 调用标签
copilot-reminder
。 我们将使用此标签来检查是否已为每个非活动用户打开提醒议题。若要创建标签,请参阅“管理标签”。
-
将提醒消息(例如 Markdown 提醒示例中提供的提醒)保存为仓库或组织中的 GitHub Actions 变量。 调用变量
COPILOT_REMINDER_MESSAGE
。若要创建变量,请参阅“在变量中存储信息”。
-
创建一个有权限调用列出组织的所有 Copilot 席位分配 API 终结点的personal access token。 例如,创建具有以下详细信息的精细令牌:
- 资源所有者:要在其中查找非活动用户的组织。
- 组织权限:GitHub Copilot Business(只读)。
若要创建令牌,请参阅“管理个人访问令牌”。
-
将访问令牌保存为仓库或组织中的 GitHub Actions 机密。 调用机密
COPILOT_LICENSE_READ
。若要创建机密,请参阅“在 GitHub Actions 中使用机密”。
-
通过使用以下示例,在要在其中创建提醒议题的仓库中创建工作流。
如果不熟悉 GitHub Actions,请参阅“GitHub Actions 快速入门”。
-
在工作流中,将
gh
命令中的ORG/REPO
占位符替换为要在其中创建提醒议题的仓库的名称。 例如:octo-org/octo-repo
。
示例工作流
Note
此示例假定你通过组织分配许可证。 如果将专用企业帐户用于 Copilot Business,则需要使用不同的 API 终结点。 请参阅 为 Copilot Business 设置专属企业(个人帐户)。
# Name your workflow name: Remind inactive users about Copilot license # Run the workflow every day at 8am UTC on: schedule: - cron: '0 8 * * *' jobs: context-log: runs-on: ubuntu-latest steps: - name: Check Copilot Last Activity id: check-last-activity run: | # Call the user management API 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/$ORGANIZATION_VAR/copilot/billing/seats) echo "Raw Response from gh api:" echo "$RESPONSE" # Parse and check each user's `last_activity_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') # Replace ORG/REPO with the repository name EXISTING_ISSUES=$(gh issue list --repo ORG/REPO --assignee $LOGIN --label 'copilot-reminder' --json id) # Convert dates to seconds since epoch for comparison LAST_ACTIVITY_DATE=$(date -d "$LAST_ACTIVITY" +%s) 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" # Replace ORG/REPO with the repository name NEW_ISSUE_URL="$(gh issue create --title "Reminder about your GitHub Copilot license" --body "${{ vars.COPILOT_REMINDER_MESSAGE }}" --repo ORG/REPO --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 GITHUB_TOKEN, required for the `gh issue` commands env: GITHUB_TOKEN: ${{ github.token }}
name: Remind inactive users about Copilot license
Name your workflow
on:
schedule:
- cron: '0 8 * * *'
jobs:
context-log:
runs-on: ubuntu-latest
steps:
- name: Check Copilot Last Activity
id: check-last-activity
run: |
Run the workflow every day at 8am UTC
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/$ORGANIZATION_VAR/copilot/billing/seats)
echo "Raw Response from gh api:"
echo "$RESPONSE"
Call the user management API
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')
Parse and check each user's last_activity_at
EXISTING_ISSUES=$(gh issue list --repo ORG/REPO --assignee $LOGIN --label 'copilot-reminder' --json id)
Replace ORG/REPO with the repository name
LAST_ACTIVITY_DATE=$(date -d "$LAST_ACTIVITY" +%s)
THIRTY_DAYS_AGO=$(date -d "30 days ago" +%s)
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"
Create issues for inactive users who don't have an existing open issue
NEW_ISSUE_URL="$(gh issue create --title "Reminder about your GitHub Copilot license" --body "${{ vars.COPILOT_REMINDER_MESSAGE }}" --repo ORG/REPO --assignee $LOGIN --label 'copilot-reminder')"
else
echo "User $LOGIN is active or already has an assigned reminder issue. Last activity: $LAST_ACTIVITY"
fi
done
Replace ORG/REPO with the repository name
env:
GITHUB_TOKEN: ${{ github.token }}
Set the GITHUB_TOKEN, required for the gh issue
commands
# Name your workflow
name: Remind inactive users about Copilot license
# Run the workflow every day at 8am UTC
on:
schedule:
- cron: '0 8 * * *'
jobs:
context-log:
runs-on: ubuntu-latest
steps:
- name: Check Copilot Last Activity
id: check-last-activity
run: |
# Call the user management API
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/$ORGANIZATION_VAR/copilot/billing/seats)
echo "Raw Response from gh api:"
echo "$RESPONSE"
# Parse and check each user's `last_activity_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')
# Replace ORG/REPO with the repository name
EXISTING_ISSUES=$(gh issue list --repo ORG/REPO --assignee $LOGIN --label 'copilot-reminder' --json id)
# Convert dates to seconds since epoch for comparison
LAST_ACTIVITY_DATE=$(date -d "$LAST_ACTIVITY" +%s)
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"
# Replace ORG/REPO with the repository name
NEW_ISSUE_URL="$(gh issue create --title "Reminder about your GitHub Copilot license" --body "${{ vars.COPILOT_REMINDER_MESSAGE }}" --repo ORG/REPO --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 GITHUB_TOKEN, required for the `gh issue` commands
env:
GITHUB_TOKEN: ${{ github.token }}