Skip to content

Commit 4c95f94

Browse files
committed
bum pt 0.2.11
1 parent 50e557b commit 4c95f94

13 files changed

Lines changed: 2416 additions & 10019 deletions

.github/workflows/deploy.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ permissions:
99
contents: read
1010
pages: write
1111
id-token: write
12+
packages: read
13+
actions: read # <-- needed to read workflow runs/jobs
14+
checks: read # <-- needed to read check runs
15+
statuses: read # <-- needed to read commit statuses
16+
pull-requests: write
17+
issues: write
1218

1319
concurrency:
1420
group: "pages"
@@ -28,7 +34,10 @@ jobs:
2834
uses: actions/setup-node@v4
2935
with:
3036
node-version: '20'
31-
37+
registry-url: 'https://npm.pkg.github.com'
38+
scope: '@nss-workshops'
39+
env:
40+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3241
- name: Create env file
3342
run: |
3443
echo "VITE_OAUTH_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}" > .env
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: PR Preview to S3 Website (Vite)
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, closed]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
packages: read
12+
actions: read # <-- needed to read workflow runs/jobs
13+
checks: read # <-- needed to read check runs
14+
statuses: read # <-- needed to read commit statuses
15+
pull-requests: write
16+
issues: write
17+
18+
env:
19+
NODE_VERSION: '20'
20+
21+
jobs:
22+
build-and-deploy:
23+
if: github.event.action != 'closed'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ env.NODE_VERSION }}
31+
cache: npm
32+
registry-url: 'https://npm.pkg.github.com'
33+
scope: '@nss-workshops'
34+
env:
35+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Create env file
37+
run: |
38+
echo "VITE_OAUTH_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}" > .env
39+
echo "VITE_OAUTH_CLIENT_SECRET=${{ secrets.OAUTH_CLIENT_SECRET }}" >> .env
40+
echo "VITE_PROXY_DOMAIN=https://authproxy.nss.team" >> .env
41+
echo "VITE_LEARNING_PLATFORM_API=https://learningapi.nss.team" >> .env
42+
echo "BASE_URL=pr-${{ github.event.pull_request.number }}" >> .env
43+
- name: Install dependencies
44+
run: npm ci
45+
env:
46+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Build Vite
49+
run: npm run build
50+
51+
- name: Configure AWS (OIDC)
52+
uses: aws-actions/configure-aws-credentials@v4
53+
with:
54+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
55+
aws-region: ${{ vars.AWS_REGION }}
56+
57+
- name: Upload to S3 (prefix = pr-<num>)
58+
run: |
59+
set -euo pipefail
60+
PR=${{ github.event.pull_request.number }}
61+
aws s3 sync ./dist "s3://${{ vars.S3_BUCKET }}/pr-${PR}/" --delete --only-show-errors
62+
echo "PREVIEW_URL=${{ vars.S3_WEBSITE_BASE }}/pr-${PR}/" >> "$GITHUB_ENV"
63+
64+
- name: Comment PR with preview URL
65+
uses: actions/github-script@v7
66+
with:
67+
script: |
68+
const url = process.env.PREVIEW_URL;
69+
const curlCmd = `curl -I "${url}"`;
70+
const body = [
71+
"🚀 **Vite Preview Deployed (S3 Website)**",
72+
"",
73+
`**URL:** ${url}`,
74+
"",
75+
"Quick check:",
76+
"```bash",
77+
curlCmd,
78+
"```",
79+
"",
80+
"_Note: S3 website endpoints are HTTP-only. Add CloudFront later if you need HTTPS._"
81+
].join("\n");
82+
await github.rest.issues.createComment({
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
issue_number: context.issue.number,
86+
body
87+
});
88+
89+
cleanup:
90+
if: github.event.action == 'closed'
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Configure AWS (OIDC)
94+
uses: aws-actions/configure-aws-credentials@v4
95+
with:
96+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
97+
aws-region: ${{ vars.AWS_REGION }}
98+
99+
- name: Delete S3 prefix
100+
run: |
101+
set -euo pipefail
102+
PR=${{ github.event.pull_request.number }}
103+
aws s3 rm "s3://${{ vars.S3_BUCKET }}/pr-${PR}/" --recursive --only-show-errors
104+
echo "PREVIEW_URL=${{ vars.S3_WEBSITE_BASE }}/pr-${PR}/" >> "$GITHUB_ENV"
105+
106+
- name: Comment PR with cleanup confirmation
107+
uses: actions/github-script@v7
108+
with:
109+
script: |
110+
const url = process.env.PREVIEW_URL;
111+
const body = `🧹 **Preview deleted** for this PR.\n\n(removed content behind: ${url})`;
112+
await github.rest.issues.createComment({
113+
owner: context.repo.owner,
114+
repo: context.repo.repo,
115+
issue_number: context.issue.number,
116+
body
117+
});

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,18 @@ projectBrief.md
3131
.roo/
3232
.roomodes
3333
memory-bank/
34+
35+
.roo/
36+
.roomodes
37+
context_portal/
38+
memory-bank/
39+
40+
.roo/
41+
.roomodes
42+
context_portal/
43+
memory-bank/
44+
45+
.roo/
46+
.roomodes
47+
context_portal/
48+
memory-bank/

.npmrc

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

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
sessionStorage.removeItem('redirect');
1616

1717
// Ensure we're in the correct basename
18-
var basePath = '/data-structures-and-algorithms';
18+
var basePath = '/%COURSE_URL%';
1919
if (window.location.pathname.indexOf(basePath) === 0) {
2020
// Use history API to navigate to the correct route without a page reload
2121
var targetPath = basePath + redirect;

0 commit comments

Comments
 (0)