You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEPLOYMENT.md
+32-27Lines changed: 32 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,19 @@ There are a few ways to deploy the Copilot Metrics Viewer, depending on the type
4
4
5
5
The app runs in a Docker container, so it can be deployed anywhere containers are hosted (AWS, GCP, Azure, Kubernetes, etc.).
6
6
7
-
## Authentication to GitHub
7
+
## Deployment options
8
+
9
+
Review available [Nuxt Deployment Options](https://nuxt.com/deploy).
10
+
11
+
>[!WARNING]
12
+
> Copilot Metrics Viewer requires a backend, hence it cannot be deployed as a purely static web app.
13
+
14
+
## Authentication with GitHub
8
15
9
16
The Metrics Viewer can be integrated with GitHub application authentication, which authenticates the user and verifies their permissions to view the metrics. This option is recommended since it doesn't use Personal Access Tokens. The downside of using a GitHub application is that it can only authorize users to view metrics at the organization level (no support for Enterprise).
10
17
18
+
For Enterprise level authentication review [Github OAuth Apps](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps).
19
+
11
20
With a Personal Access Token, user credentials are not verified, and the application simply renders Copilot metrics fetched using the PAT stored in the backend.
12
21
13
22
## Authentication for Copilot Metrics Viewer
@@ -27,7 +36,7 @@ The simplest way to deploy is to use the "one-click" option that creates resourc
27
36
28
37

29
38
30
-
Application will use a pre-built docker image hosted in GitHub registry: `ghcr.io/github-copilot-resources/copilot-metrics-viewer-with-proxy`.
39
+
Application will use a pre-built docker image hosted in GitHub registry: `ghcr.io/github-copilot-resources/copilot-metrics-viewer`.
31
40
32
41
**Prerequisites:** Contributor permission to a resource group in Azure and a subscription with the `Microsoft.App` resource provider enabled.
33
42
@@ -89,14 +98,13 @@ The deployment creates:
89
98
Before running `azd up`, configure GitHub variables:
90
99
91
100
```bash
92
-
azd env set VUE_APP_SCOPE <organization/enterprise>
101
+
azd env set NUXT_PUBLIC_SCOPE <organization/enterprise>
93
102
# when using organization
94
-
azd env set VUE_APP_GITHUB_ORG <org name>
103
+
azd env set NUXT_PUBLIC_GITHUB_ORG <org name>
95
104
# when using enterprise
96
-
azd env set VUE_APP_GITHUB_ENT <ent name>
97
-
azd env set VUE_APP_GITHUB_API /api/github
98
-
azd env set GITHUB_CLIENT_ID <client id>
99
-
azd env set GITHUB_CLIENT_SECRET <client secret for the GH App>
105
+
azd env set NUXT_PUBLIC_GITHUB_ENT <ent name>
106
+
azd env set NUXT_OAUTH_GITHUB_CLIENT_ID <client id>
107
+
azd env set NUXT_OAUTH_GITHUB_CLIENT_SECRET <client secret for the GH App>
100
108
```
101
109
102
110
## Scenario 3: Deploying the container
@@ -107,37 +115,34 @@ For GitHub App:
107
115
108
116
```bash
109
117
docker run -it --rm -p 3000:3000 \
110
-
-e VUE_APP_SCOPE=organization \
111
-
-e VUE_APP_GITHUB_API=/api/github \
112
-
-e VUE_APP_GITHUB_ORG=<org name> \
113
-
-e GITHUB_CLIENT_ID=<client id> \
114
-
-e GITHUB_CLIENT_SECRET=<client secret for the GH App> \
Copy file name to clipboardExpand all lines: README.md
+60-80Lines changed: 60 additions & 80 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,48 +89,91 @@ The language breakdown analysis tab also displays a table showing the Accepted P
89
89
90
90
In the `.env` file, you can configure several environment variables that control the behavior of the application.
91
91
92
-
#### VUE_APP_SCOPE
92
+
Public variables:
93
+
-`NUXT_PUBLIC_IS_DATA_MOCKED`
94
+
-`NUXT_PUBLIC_SCOPE`
95
+
-`NUXT_PUBLIC_GITHUB_ENT`
96
+
-`NUXT_PUBLIC_GITHUB_ORG`
97
+
-`NUXT_PUBLIC_GITHUB_TEAM`
93
98
94
-
The `VUE_APP_SCOPE` environment variable in the `.env` file determines the scope of the API calls made by the application. It can be set to either 'enterprise' or 'organization'.
- If set to 'enterprise', the application will target API calls to the GitHub Enterprise account defined in the `VUE_APP_GITHUB_ENT` variable.
97
-
- If set to 'organization', the application will target API calls to the GitHub Organization account defined in the `VUE_APP_GITHUB_ORG` variable.
105
+
#### NUXT_PUBLIC_SCOPE
98
106
99
-
For example, if you want to target the API calls to an organization, you would set `VUE_APP_SCOPE=organization` in the `.env` file.
107
+
The `NUXT_PUBLIC_SCOPE` environment variable in the `.env` file determines the default scope of the API calls made by the application. It can be set to 'enterprise', 'organization' or 'team'.
108
+
109
+
- If set to 'enterprise', the application will target API calls to the GitHub Enterprise account defined in the `NUXT_PUBLIC_GITHUB_ENT` variable.
110
+
- If set to 'organization', the application will target API calls to the GitHub Organization account defined in the `NUXT_PUBLIC_GITHUB_ORG` variable.
111
+
- If set to 'team', the application will target API calls to GitHub Team defined in the `NUXT_PUBLIC_GITHUB_TEAM` variable under `NUXT_PUBLIC_GITHUB_ORG` GitHub Organization.
112
+
113
+
For example, if you want to target the API calls to an organization, you would set `NUXT_PUBLIC_SCOPE=organization` in the `.env` file.
114
+
115
+
>[!INFO]
116
+
> Environment variables with `NUXT_PUBLIC` scope are available in the browser (are public).
117
+
> See [Nuxt Runtime Config](https://nuxt.com/docs/guide/going-further/runtime-config) for details.
100
118
101
119
````
102
-
VUE_APP_SCOPE=organization
120
+
NUXT_PUBLIC_SCOPE=organization
103
121
104
-
VUE_APP_GITHUB_ORG=<YOUR-ORGANIZATION>
122
+
NUXT_PUBLIC_GITHUB_ORG=<YOUR-ORGANIZATION>
105
123
106
-
VUE_APP_GITHUB_ENT=
124
+
NUXT_PUBLIC_GITHUB_ENT=
107
125
````
108
126
109
-
#### VUE_APP_GITHUB_TEAM
127
+
#### NUXT_PUBLIC_GITHUB_TEAM
110
128
111
-
The `VUE_APP_GITHUB_TEAM` environment variable filters metrics for a specific GitHub team within an Enterprise or Organization account.
129
+
The `NUXT_PUBLIC_GITHUB_TEAM` environment variable filters metrics for a specific GitHub team within an Enterprise or Organization account.
112
130
‼️ Important ‼️ When this variable is set, all displayed metrics will pertain exclusively to the specified team. To view metrics for the entire Organization or Enterprise, remove this environment variable.
113
131
132
+
>[!WARNING]
133
+
> GitHub provides Team metrics [for a given day if the team had five or more members with active Copilot licenses, as evaluated at the end of that day.](https://docs.github.com/en/rest/copilot/copilot-usage?apiVersion=2022-11-28#get-a-summary-of-copilot-usage-for-a-team).
134
+
114
135
````
115
-
VUE_APP_GITHUB_TEAM=
136
+
NUXT_PUBLIC_GITHUB_TEAM=
116
137
````
117
138
118
-
#### VUE_APP_MOCKED_DATA
139
+
#### NUXT_PUBLIC_IS_DATA_MOCKED
119
140
120
-
To access Copilot metrics from the last 28 days via the API and display actual data, set the following boolean environment variable to `false`:
141
+
Variable is false by default. To view mocked data switch it to true or use query parameter `?mock=true`.
121
142
122
143
````
123
-
VUE_APP_MOCKED_DATA=false
144
+
NUXT_PUBLIC_IS_DATA_MOCKED=false
124
145
````
125
146
126
-
#### VUE_APP_GITHUB_TOKEN
147
+
#### NUXT_GITHUB_TOKEN
127
148
128
149
Specifies the GitHub Personal Access Token utilized for API requests. Generate this token with the following scopes: _copilot_, _manage_billing:copilot_, _manage_billing:enterprise_, _read:enterprise_, _read:org_.
129
150
151
+
Token is not used in the frontend.
152
+
130
153
````
131
-
VUE_APP_GITHUB_TOKEN=
154
+
NUXT_GITHUB_TOKEN=
132
155
````
133
156
157
+
#### NUXT_SESSION_PASSWORD (Required!)
158
+
159
+
This variable is required to encrypt user sessions, it needs to be at least 32 characters long.
160
+
For more information see [Nuxt Sessions and Authentication](https://nuxt.com/docs/guide/recipes/sessions-and-authentication#cookie-encryption-key).
161
+
162
+
>[!WARNING]
163
+
> This variable is required starting from version 2.0.0.
164
+
165
+
#### NUXT_PUBLIC_USING_GITHUB_AUTH
166
+
167
+
Default is `false`. When set to `true`, GitHub OAuth App Authentication will be performed to verify users' access to the dashboard.
168
+
169
+
Variables required for GitHub Auth are:
170
+
1.`NUXT_OAUTH_GITHUB_CLIENT_ID` - client ID of the GitHub App registered and installed in the enterprise/org with permissions listed in [NUXT_GITHUB_TOKEN](#NUXT_GITHUB_TOKEN).
171
+
2.`NUXT_OAUTH_GITHUB_CLIENT_SECRET` - client secret of the GitHub App.
172
+
3.[Optional]`NUXT_OAUTH_GITHUB_CLIENT_SCOPE` for scope requests when using OAuth App instead of GitHub App. See [Github docs](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps) for details.
173
+
174
+
>[!WARNING]
175
+
> Only users with permissions (scopes listed in [NUXT_GITHUB_TOKEN](#NUXT_GITHUB_TOKEN)) can view copilot metrics, GitHub uses the authenticated users permissions to make API calls for data.
The application will be accessible at http://localhost:8080
159
202
160
-
## Running with API Proxy
161
-
162
-
The project can run with an API proxy which hides GitHub tokens and is secure enough to be deployed.
163
-
The API Proxy project is in the `\api` directory. The Vue app makes the calls to `/api/github` which are then proxied to `https://api.github.com` with the appropriate bearer token.
164
-
165
-
The proxy can authenticate the user using a GitHub App. In order to do that, the following environment variables are required:
166
-
167
-
*`GITHUB_CLIENT_ID` - client ID of the GitHub App registered and installed in the enterprise/org with permissions listed above.
168
-
*`GITHUB_CLIENT_SECRET` - client secret of the GitHub App.
169
-
*`SESSION_SECRET` - random string for securing session state.
170
-
171
-
If you want to use a custom path for your `.env` file, you can set the environment variable `DOTENV_CONFIG_PATH`.
172
-
173
-
It's also possible to run with a **PAT Token**, see examples below for required variables.
174
-
175
-
For local development, register `http://localhost:3000/callback` as the GitHub App callback URI.
176
-
For the deployed version, use the URI of your app.
0 commit comments