Skip to content

Commit fb6389c

Browse files
committed
feat(internal): 🚧 Try to print out the branch name of a PR, both in GH:A and from Vercel
This is a test to check what the values actually are for use when making per-pr DB branches
1 parent 68026d2 commit fb6389c

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Print out some useful information about the PR
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- closed
10+
11+
jobs:
12+
setup:
13+
outputs:
14+
branch: ${{ steps.branch_name.outputs.current_branch }}
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
steps:
19+
- name: Get branch name
20+
id: branch_name
21+
uses: tj-actions/branch-names@v8
22+
23+
when_open:
24+
name: When open
25+
needs: setup
26+
if: |
27+
github.event_name == 'pull_request' && (
28+
github.event.action == 'synchronize'
29+
|| github.event.action == 'opened'
30+
|| github.event.action == 'reopened')
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Print branch name
34+
env:
35+
CURRENT_BRANCH: ${{needs.setup.outputs.branch}}
36+
run: |
37+
echo "Branch name: $CURRENT_BRANCH"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { env } from "~/env";
2+
3+
import {
4+
Table,
5+
TableBody,
6+
TableCell,
7+
TableHead,
8+
TableHeader,
9+
TableRow,
10+
} from "~/components/ui/table";
11+
12+
export const dynamic = "force-dynamic";
13+
14+
export default function AdvancedSiteInfo() {
15+
// WARNING: Be **very** careful about what you expose here,
16+
// since this is a server component it is able to expose server side only environment variables,
17+
// which includes things like API tokens and other secrets
18+
// **DO NOT** expose things that must be secret
19+
20+
return (
21+
<main className="container prose pt-8 lg:prose-xl dark:prose-invert">
22+
<h1>Advanced information about MCC Gadgets</h1>
23+
<p>
24+
Warning! Here be dragons! This page presents various pieces of advanced
25+
information about the website, you probably don&apos;t need to know
26+
about this stuff, maybe think again about what brought you to this page
27+
</p>
28+
<p>
29+
Eventually this page will be locked behind specific permissions, but
30+
currently that isn&apos;t implemented
31+
</p>
32+
<Table>
33+
<TableHeader>
34+
<TableRow>
35+
<TableHead>Key</TableHead>
36+
<TableHead>Value</TableHead>
37+
</TableRow>
38+
</TableHeader>
39+
<TableBody>
40+
<EnvVarRow envVar="VERCEL_GIT_COMMIT_REF" />
41+
</TableBody>
42+
</Table>
43+
</main>
44+
);
45+
}
46+
47+
function EnvVarRow({ envVar }: { envVar: keyof typeof env }) {
48+
const value = env[envVar];
49+
return (
50+
<TableRow>
51+
<TableCell>{envVar}</TableCell>
52+
<TableCell>
53+
{typeof value === "undefined" ? "undefined" : value}
54+
</TableCell>
55+
</TableRow>
56+
);
57+
}

‎src/env.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const env = createEnv({
2525
),
2626
DISCORD_CLIENT_ID: z.string(),
2727
DISCORD_CLIENT_SECRET: z.string(),
28+
VERCEL_GIT_COMMIT_REF: z.string().optional(),
2829
},
2930

3031
/**
@@ -48,6 +49,7 @@ export const env = createEnv({
4849
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
4950
DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
5051
DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
52+
VERCEL_GIT_COMMIT_REF: process.env.VERCEL_GIT_COMMIT_REF,
5153
},
5254
/**
5355
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially

0 commit comments

Comments
 (0)