Skip to content

Commit 2c54629

Browse files
authored
Merge pull request #144 from github-copilot-resources/feature/nuxt
Updated code to use Nuxt3. Resolved all old dependencies. I tried to keep as much backward compatibility as possible: - kept old port - kept environment variable names >[!WARNING] > One breaking change is required to have `NUXT_SESSION_PASSWORD` (at least 32 characters long) which is used to encrypt session cookies. This pull request includes several changes to improve the deployment process, update environment variables, and streamline the Docker configuration. The most important changes include modifications to `.env` variables, Dockerfile updates, and workflow adjustments. ### Environment Variables Update: * Updated environment variables in `.env` to use `NUXT_PUBLIC` prefix instead of `VUE_APP`, and added new variables for GitHub OAuth and session password. ### Docker Configuration: * Updated `Dockerfile` to support different build modes (`prod` and `playwright`) and re-mapped environment variables for backwards compatibility. ### Workflow Adjustments: * Simplified GitHub workflows by removing redundant steps and adding new steps for building and testing the application. Changes include removing `push_proxy_to_ghcr` job and updating metadata-action configurations. [[1]](diffhunk://#diff-5af7c79204beb4acab8f83732bff158a2634f096816a28de30abc47991ff12beL35-R38) [[2]](diffhunk://#diff-5af7c79204beb4acab8f83732bff158a2634f096816a28de30abc47991ff12beL55-L95) [[3]](diffhunk://#diff-6df416bddea2a269641d3989e10ddfeb271585b3cb02478c48d019783a8c92a3L36-R38) [[4]](diffhunk://#diff-6df416bddea2a269641d3989e10ddfeb271585b3cb02478c48d019783a8c92a3L56-L99) [[5]](diffhunk://#diff-280f7f21d8a181010de13b86b88749532922230de2930048cf4642c0e315fab6L41-L43) [[6]](diffhunk://#diff-280f7f21d8a181010de13b86b88749532922230de2930048cf4642c0e315fab6L83-R82) [[7]](diffhunk://#diff-280f7f21d8a181010de13b86b88749532922230de2930048cf4642c0e315fab6L102-L143) * Updated Playwright workflow to include a build step and consolidated Docker-based Playwright tests. [[1]](diffhunk://#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R35-R50) [[2]](diffhunk://#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3L89-R73) ### Documentation: * Updated `DEPLOYMENT.md` to reflect changes in environment variables and deployment options, and removed references to the legacy `-with-proxy` image. [[1]](diffhunk://#diff-04615394c116398fb5fcb0aa2d880df854202e4c94907dc81cd2647101ad3306L7-R19) [[2]](diffhunk://#diff-04615394c116398fb5fcb0aa2d880df854202e4c94907dc81cd2647101ad3306L30-R39) [[3]](diffhunk://#diff-04615394c116398fb5fcb0aa2d880df854202e4c94907dc81cd2647101ad3306L92-R107) [[4]](diffhunk://#diff-04615394c116398fb5fcb0aa2d880df854202e4c94907dc81cd2647101ad3306L110-R145) ### Miscellaneous: * Added `.vscode/launch.json` for debugging configurations in Visual Studio Code.
2 parents 612d7d9 + b1fc803 commit 2c54629

File tree

104 files changed

+14476
-12409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+14476
-12409
lines changed

.browserslistrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ infra/
2424
/test-results-docker/
2525
test-results-docker-ent/
2626
test-results-docker-org/
27+
28+
.nuxt/
29+
.output/
30+
.vscode/
31+
dist/

.env

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# Determines if mocked data should be used instead of making API calls.
2-
VUE_APP_MOCKED_DATA=true
2+
NUXT_PUBLIC_IS_DATA_MOCKED=true
33

44
# Determines the scope of the API calls.
55
# Can be 'enterprise' or 'organization' to target API calls to an enterprise or an organization respectively.
6-
VUE_APP_SCOPE=organization
6+
NUXT_PUBLIC_SCOPE=organization
77

88
# Determines the enterprise or organization name to target API calls.
9-
VUE_APP_GITHUB_ORG=octodemo
9+
NUXT_PUBLIC_GITHUB_ORG=octodemo
1010

11-
VUE_APP_GITHUB_ENT=
11+
NUXT_PUBLIC_GITHUB_ENT=
1212

1313
# Determines the team name if exists to target API calls.
14-
VUE_APP_GITHUB_TEAM=
14+
NUXT_PUBLIC_GITHUB_TEAM=
15+
16+
NUXT_PUBLIC_USING_GITHUB_AUTH=false
1517

1618
# Determines the GitHub Personal Access Token to use for API calls.
1719
# Create with scopes copilot, manage_billing:copilot or manage_billing:enterprise, read:enterprise AND read:org
18-
VUE_APP_GITHUB_TOKEN=
20+
# NUXT_GITHUB_TOKEN=<TOKEN>
1921

20-
# GitHub Api Url
21-
# for proxy api - set to /api/github defaults to https://api.github.com
22-
VUE_APP_GITHUB_API=
22+
NUXT_SESSION_PASSWORD=something_long_and_random_thats_at_least_32_characters
2323

24-
# Random string used in API to secure session, use when VUE_APP_GITHUB_API=/api/github
25-
#SESSION_SECRET=randomstring
24+
# for Github OAuth
25+
NUXT_OAUTH_GITHUB_CLIENT_ID=
26+
NUXT_OAUTH_GITHUB_CLIENT_SECRET=

.eslintrc.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/deploy_to_ghcr.yml

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ jobs:
3232
id: meta
3333
uses: docker/metadata-action@v5
3434
with:
35-
images: ghcr.io/${{ github.repository }}
35+
# this is back a single image, `-with-proxy` is legacy and will be removed
36+
images: |
37+
ghcr.io/${{ github.repository }}
38+
ghcr.io/${{ github.repository }}-with-proxy
3639
labels: |
3740
org.opencontainers.image.title=copilot-metrics-viewer
3841
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
@@ -52,47 +55,6 @@ jobs:
5255
labels: ${{ steps.meta.outputs.labels }}
5356
push: true
5457

55-
push_proxy_to_ghcr:
56-
runs-on: ubuntu-latest
57-
steps:
58-
- name: Checkout GitHub Action
59-
uses: actions/checkout@v4
60-
61-
- name: Login to GitHub Container Registry
62-
uses: docker/login-action@v3
63-
with:
64-
registry: ghcr.io
65-
username: ${{ github.actor }}
66-
password: ${{ secrets.GITHUB_TOKEN }}
67-
68-
# Adding below tag any push to main as "latest"
69-
# To deploy latest, create a release with a semver tag
70-
# type=raw,value=latest,enable={{is_default_branch}}
71-
- name: Extract metadata
72-
id: meta
73-
uses: docker/metadata-action@v5
74-
with:
75-
images: ghcr.io/${{ github.repository }}-with-proxy
76-
labels: |
77-
org.opencontainers.image.title=copilot-metrics-viewer-with-proxy
78-
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
79-
org.opencontainers.image.source=${{ github.repository }}
80-
tags: |
81-
type=sha
82-
type=ref,event=branch
83-
type=ref,event=pr
84-
type=semver,pattern={{version}}
85-
type=semver,pattern={{major}}.{{minor}}
86-
87-
- name: Build and push api
88-
uses: docker/build-push-action@v5
89-
with:
90-
context: .
91-
file: api.Dockerfile
92-
tags: ${{ steps.meta.outputs.tags }}
93-
labels: ${{ steps.meta.outputs.labels }}
94-
push: true
95-
9658
deploy:
9759
runs-on: ubuntu-latest
9860
needs: push_to_ghcr

.github/workflows/deploy_to_ghcr_custom_tag.yaml

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ jobs:
3737
id: meta
3838
uses: docker/metadata-action@v5
3939
with:
40-
images: ghcr.io/${{ github.repository }}
40+
images: |
41+
ghcr.io/${{ github.repository }}
42+
ghcr.io/${{ github.repository }}-with-proxy
4143
labels: |
4244
org.opencontainers.image.title=copilot-metrics-viewer
4345
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
@@ -58,48 +60,3 @@ jobs:
5860
tags: ${{ steps.meta.outputs.tags }}
5961
labels: ${{ steps.meta.outputs.labels }}
6062
push: true
61-
62-
push_proxy_to_ghcr:
63-
runs-on: ubuntu-latest
64-
steps:
65-
- name: Checkout GitHub Action
66-
uses: actions/checkout@v4
67-
with:
68-
fetch-depth: 0 # Fetch all history for all tags and branches
69-
ref: ${{ github.event.inputs.tag }}
70-
71-
72-
- name: Login to GitHub Container Registry
73-
uses: docker/login-action@v3
74-
with:
75-
registry: ghcr.io
76-
username: ${{ github.actor }}
77-
password: ${{ secrets.GITHUB_TOKEN }}
78-
79-
- name: Extract metadata
80-
id: meta
81-
uses: docker/metadata-action@v5
82-
with:
83-
images: ghcr.io/${{ github.repository }}-with-proxy
84-
labels: |
85-
org.opencontainers.image.title=copilot-metrics-viewer-with-proxy
86-
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
87-
org.opencontainers.image.source=${{ github.repository }}
88-
tags: |
89-
type=raw,enable=true,priority=1,value=${{ github.event.inputs.tag }}
90-
type=raw,enable=${{ github.event.inputs.include_latest }},priority=2,value=latest
91-
type=sha
92-
type=ref,event=branch
93-
type=ref,event=pr
94-
type=semver,pattern={{version}}
95-
type=semver,pattern={{major}}.{{minor}}
96-
97-
- name: Build and push api
98-
uses: docker/build-push-action@v5
99-
with:
100-
context: .
101-
file: api.Dockerfile
102-
tags: ${{ steps.meta.outputs.tags }}
103-
labels: ${{ steps.meta.outputs.labels }}
104-
push: true
105-

.github/workflows/deploy_to_ghcr_tag_release.yaml

Lines changed: 42 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,54 @@ permissions:
1515
pull-requests: write
1616

1717
jobs:
18-
version_update:
19-
runs-on: ubuntu-latest
20-
steps:
21-
- name: Checkout GitHub Action
22-
uses: actions/checkout@v4
23-
with:
24-
fetch-depth: 0
18+
# version_update:
19+
# runs-on: ubuntu-latest
20+
# steps:
21+
# - name: Checkout GitHub Action
22+
# uses: actions/checkout@v4
23+
# with:
24+
# fetch-depth: 0
2525

26-
- uses: actions4git/setup-git@v1
26+
# - uses: actions4git/setup-git@v1
2727

28-
- name: Update version in package.json
29-
id: version
30-
run: |
31-
git checkout main
32-
version=$(npm version from-git --no-git-tag-version)
33-
echo "version=$version" >> $GITHUB_OUTPUT
34-
echo "NPM version is $version"
28+
# - name: Update version in package.json
29+
# id: version
30+
# run: |
31+
# git checkout main
32+
# version=$(npm version from-git --no-git-tag-version)
33+
# echo "version=$version" >> $GITHUB_OUTPUT
34+
# echo "NPM version is $version"
3535

36-
if [ "${{ github.event.release.tag_name }}" != "$version" ]; then
37-
echo "Release tag does not match the expected version."
38-
exit 1
39-
fi
36+
# if [ "${{ github.event.release.tag_name }}" != "$version" ]; then
37+
# echo "Release tag does not match the expected version."
38+
# exit 1
39+
# fi
4040

41-
cd api
42-
npm version from-git --no-git-tag-version
43-
cd ..
44-
git add .
45-
git commit --signoff --message $version
41+
# git add .
42+
# git commit --signoff --message $version
4643

47-
- name: Create Pull Request
48-
uses: peter-evans/create-pull-request@v7
49-
continue-on-error: true
50-
with:
51-
title: '🚀Update version to ${{ steps.version.outputs.version }}'
52-
body: |
53-
This PR updates the version to ${{ steps.version.outputs.version }}.
54-
Use **merge commit** strategy for this PR!
55-
branch: 'version-update-${{ steps.version.outputs.version }}'
56-
delete-branch: true
57-
labels: 'version-update'
58-
base: 'main'
44+
# - name: Create Pull Request
45+
# uses: peter-evans/create-pull-request@v7
46+
# continue-on-error: true
47+
# with:
48+
# title: '🚀Update version to ${{ steps.version.outputs.version }}'
49+
# body: |
50+
# This PR updates the version to ${{ steps.version.outputs.version }}.
51+
# Use **merge commit** strategy for this PR!
52+
# branch: 'version-update-${{ steps.version.outputs.version }}'
53+
# delete-branch: true
54+
# labels: 'version-update'
55+
# base: 'main'
5956

60-
- name: Move tag ${{ steps.version.outputs.version }} to PR
61-
run: |
62-
echo "moving tag ${{ steps.version.outputs.version }}"
63-
git tag --force ${{ steps.version.outputs.version }}
64-
git push origin ${{ steps.version.outputs.version }} --force
57+
# - name: Move tag ${{ steps.version.outputs.version }} to PR
58+
# run: |
59+
# echo "moving tag ${{ steps.version.outputs.version }}"
60+
# git tag --force ${{ steps.version.outputs.version }}
61+
# git push origin ${{ steps.version.outputs.version }} --force
6562

6663
push_to_ghcr:
6764
runs-on: ubuntu-latest
68-
needs: version_update
65+
# needs: version_update
6966
steps:
7067
- name: Checkout GitHub Action
7168
uses: actions/checkout@v4
@@ -83,7 +80,9 @@ jobs:
8380
id: meta
8481
uses: docker/metadata-action@v5
8582
with:
86-
images: ghcr.io/${{ github.repository }}
83+
images: |
84+
ghcr.io/${{ github.repository }}
85+
ghcr.io/${{ github.repository }}-with-proxy
8786
labels: |
8887
org.opencontainers.image.title=copilot-metrics-viewer
8988
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
@@ -103,46 +102,3 @@ jobs:
103102
tags: ${{ steps.meta.outputs.tags }}
104103
labels: ${{ steps.meta.outputs.labels }}
105104
push: true
106-
107-
push_proxy_to_ghcr:
108-
runs-on: ubuntu-latest
109-
needs: version_update
110-
steps:
111-
- name: Checkout GitHub Action
112-
uses: actions/checkout@v4
113-
with:
114-
ref: ${{ github.event.release.tag_name }}
115-
116-
- name: Login to GitHub Container Registry
117-
uses: docker/login-action@v3
118-
with:
119-
registry: ghcr.io
120-
username: ${{ github.actor }}
121-
password: ${{ secrets.GITHUB_TOKEN }}
122-
123-
- name: Extract metadata
124-
id: meta
125-
uses: docker/metadata-action@v5
126-
with:
127-
images: ghcr.io/${{ github.repository }}-with-proxy
128-
labels: |
129-
org.opencontainers.image.title=copilot-metrics-viewer-with-proxy
130-
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
131-
org.opencontainers.image.source=${{ github.repository }}
132-
tags: |
133-
type=raw,value=latest,enable=true
134-
type=sha
135-
type=ref,event=branch
136-
type=ref,event=pr
137-
type=semver,pattern={{version}}
138-
type=semver,pattern={{major}}.{{minor}}
139-
140-
- name: Build and push api
141-
uses: docker/build-push-action@v5
142-
with:
143-
context: .
144-
file: api.Dockerfile
145-
tags: ${{ steps.meta.outputs.tags }}
146-
labels: ${{ steps.meta.outputs.labels }}
147-
push: true
148-

0 commit comments

Comments
 (0)