forked from github-copilot-resources/copilot-metrics-viewer
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
267 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node | ||
{ | ||
"name": "Node.js & TypeScript", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-18-bookworm", | ||
"features": { | ||
"ghcr.io/devcontainers-contrib/features/vue-cli:2": {} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"GitHub.copilot-chat", | ||
"GitHub.copilot" | ||
] | ||
} | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [8080], | ||
"portsAttributes": { | ||
"8080": { | ||
"protocol": "https" | ||
} | ||
}, | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "npm install" | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Build and Deploy to GitHub Pages | ||
|
||
on: | ||
workflow_dispatch: # Trigger 1: Manually via the GitHub UI | ||
workflow_run: # Trigger 2: After "Fetch GitHub Copilot Usage Metrics" workflow completes | ||
workflows: ["Fetch GitHub Copilot Usage Metrics"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
env: | ||
NAME: ${{ vars.NAME }} # Name for the org or enterprise | ||
BRANCH_NAME: ${{vars.BRANCH_NAME}} # Where the data should update to, if note set, default to data/${{ env.NAME }} | ||
steps: | ||
- name: Determine branch name | ||
run: | | ||
if [ -z "${{ env.BRANCH_NAME }}" ]; then | ||
echo "BRANCH_NAME=data/${{ env.NAME }}" >> $GITHUB_ENV | ||
fi | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{env.BRANCH_NAME}} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' # Specify your Node.js version | ||
|
||
- name: Cache Node.js modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build project | ||
run: npm run build | ||
|
||
- name: Deploy to GitHub Pages | ||
uses: JamesIves/github-pages-deploy-action@4.1.4 | ||
with: | ||
branch: gh-pages # The branch the action should deploy to. | ||
folder: dist # The folder the action should deploy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Fetch GitHub Copilot Usage Metrics | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 5 * * *' # Runs at 5 AM every day | ||
jobs: | ||
fetchData: | ||
runs-on: ubuntu-latest | ||
env: | ||
NAME: ${{ vars.NAME }} # Name for the org or enterprise | ||
VERSION: 2022-11-28 # Replace with your API version | ||
AREA: org # Replace with 'org' for organization or 'enterprise' for enterprise | ||
BRANCH_NAME: ${{vars.BRANCH_NAME}} # Where the data should update to, if note set, default to data/${{ env.NAME }} | ||
steps: | ||
- name: Determine branch name | ||
run: | | ||
if [ -z "${{ env.BRANCH_NAME }}" ]; then | ||
echo "BRANCH_NAME=data/${{ env.NAME }}" >> $GITHUB_ENV | ||
fi | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up CURL command base and Fetch data | ||
run: | | ||
if [ "${{ env.AREA }}" == "org" ]; then | ||
BASE_URL="https://api.github.com/orgs/${{ env.NAME }}" | ||
elif [ "${{ env.AREA }}" == "enterprise" ]; then | ||
BASE_URL="https://api.github.com/enterprises/${{ env.NAME }}" | ||
else | ||
echo "Invalid AREA value. Must be 'org' or 'enterprise'." >&2 | ||
exit 1 | ||
fi | ||
BASE_CURL="curl -L \ | ||
-H \"Accept: application/vnd.github+json\" \ | ||
-H \"Authorization: Bearer ${{ secrets.GH_TOKEN }}\" \ | ||
-H \"X-GitHub-Api-Version: $VERSION\"" | ||
# Fetch usage data | ||
if ! eval $BASE_CURL "$BASE_URL/copilot/usage" > ./src/assets/organization_response_sample.json; then | ||
echo "Failed to fetch usage data" >&2 | ||
exit 1 | ||
fi | ||
# Fetch seats data | ||
if ! eval $BASE_CURL "$BASE_URL/copilot/billing/seats" > ./src/assets/organization_response_sample_seats.json; then | ||
echo "Failed to fetch seats data" >&2 | ||
exit 1 | ||
fi | ||
- name: Process and commit data | ||
run: | | ||
# Example processing step | ||
echo "Processing fetched data..." | ||
# Add your data processing commands here | ||
echo "Checking for uncommitted changes..." | ||
git status | ||
if ! git diff-index --quiet HEAD --; then | ||
echo "Uncommitted changes detected, stashing..." | ||
git stash push -m "Stashing changes before switching branches" | ||
fi | ||
echo "Ensuring git fetch to update the local reference..." | ||
git fetch | ||
echo "Checking if branch exists..." | ||
if git show-ref --verify --quiet refs/heads/${{ env.BRANCH_NAME }} || git show-ref --verify --quiet refs/remotes/origin/${{ env.BRANCH_NAME }}; then | ||
echo "Branch exists, switching to it" | ||
git checkout ${{ env.BRANCH_NAME }} | ||
else | ||
echo "Branch does not exist, creating and switching to it" | ||
git checkout -b ${{ env.BRANCH_NAME }} | ||
fi | ||
echo "Configuring Git..." | ||
git config --global user.email "bot@githubaction.com" | ||
git config --global user.name "GitHub Action Bot" | ||
echo "Adding and committing changes..." | ||
git stash pop || echo "No changes to pop" | ||
git add ./src/assets/organization_response_sample.json ./src/assets/organization_response_sample_seats.json | ||
git commit -m "Updated GitHub Copilot Usage Metrics $(date -u +"%Y-%m-%dT%H:%M:%SZ")" || echo "No changes to commit" | ||
echo "Attempting to push changes..." | ||
if ! git push origin ${{ env.BRANCH_NAME }}; then | ||
echo "Failed to push changes, checking for issues..." | ||
# Handle specific push failures here, e.g., pull and merge before retrying | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters