File tree Expand file tree Collapse file tree 5 files changed +37
-23
lines changed Expand file tree Collapse file tree 5 files changed +37
-23
lines changed Original file line number Diff line number Diff line change 1111 env :
1212 PREVIEW_HOSTNAME : ep-preview.click
1313 GITHUB_BRANCH_NAME : ${{ github.head_ref || github.ref_name }}
14+ GITHUB_COMMIT_HASH : ${{ github.event.pull_request.head.sha }}
1415
1516 steps :
1617 - name : Checkout
@@ -33,15 +34,12 @@ jobs:
3334 - name : Install dependencies
3435 run : make install
3536
36- - name : Get current branch name
37- run : |
38- BRANCH_NAME=$(make safe_branch BRANCH=$GITHUB_BRANCH_NAME)
39- echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
40-
4137 - name : Build the website
42- run :
43- make build MODE=preview
44- SITE_URL="https://${BRANCH_NAME}.ep-preview.click"
38+ env :
39+ BRANCH : " ${{ env.GITHUB_BRANCH_NAME }}"
40+ GIT_VERSION : " ${{ env.GITHUB_COMMIT_HASH }}"
41+ MODE : " preview"
42+ run : make build
4543
4644 - name : Set up SSH key
4745 uses :
webfactory/[email protected] 5250 run : ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts
5351
5452 - name : Upload preview
55- run : make preview BRANCH=$GITHUB_BRANCH_NAME
53+ env :
54+ BRANCH : " ${{ env.GITHUB_BRANCH_NAME }}"
55+ run : make preview
5656
5757 - name : Update PR Comment
5858 uses : actions/github-script@v7
8080 }
8181 });
8282
83- const branch_name = process.env.BRANCH_NAME ;
83+ const branch_name = process.env.GITHUB_BRANCH_NAME ;
8484 const url = "https://" + branch_name + "." + process.env.PREVIEW_HOSTNAME;
8585 const timestamp = new Date().toISOString();
8686 const header = "\n|Key|Value|\n|---|---|\n"
Original file line number Diff line number Diff line change @@ -13,20 +13,31 @@ import deleteUnusedImages from "astro-delete-unused-images";
1313import preload from "astro-preload" ;
1414import { execSync } from "node:child_process" ;
1515
16- let gitVersion = "" ;
17- try {
18- gitVersion = execSync ( "git rev-parse --short HEAD 2>&1 > /dev/null" ) ;
19- } catch ( e ) { }
16+ let gitVersion = String ( process . env . GIT_VERSION ?? "" ) . slice ( 0 , 7 ) ;
17+
18+ if ( ! gitVersion ) {
19+ try {
20+ gitVersion = execSync ( "git rev-parse --short HEAD" , {
21+ stdio : [ "ignore" , "pipe" , "ignore" ] ,
22+ } )
23+ . toString ( )
24+ . trim ( ) ;
25+ } catch {
26+ gitVersion = "unknown" ;
27+ }
28+ }
2029
2130// https://astro.build/config
2231export default defineConfig ( {
2332 vite : {
2433 define : {
25- "import.meta.env.TIMESTAMP" : new Date ( )
26- . toISOString ( )
27- . replace ( / [ - : T . Z ] / g, "" )
28- . slice ( 0 , 14 ) ,
29- "import.meta.env.GIT_VERSION" : new String ( gitVersion ) ,
34+ __TIMESTAMP__ : JSON . stringify (
35+ new Date ( )
36+ . toISOString ( )
37+ . replace ( / [ - : T . Z ] / g, "" )
38+ . slice ( 0 , 14 )
39+ ) ,
40+ __GIT_VERSION__ : JSON . stringify ( gitVersion ) ,
3041 } ,
3142 resolve : {
3243 alias : {
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ interface Props {
55 image? : string ;
66}
77
8- const buildTimestamp = import . meta . env . TIMESTAMP ;
9- const gitVersion = import . meta . env . GIT_VERSION ;
8+ const buildTimestamp = __TIMESTAMP__ ;
9+ const gitVersion = __GIT_VERSION__ ;
1010const canonicalURL = new URL (Astro .url .pathname , Astro .site );
1111
1212const { title, description, image = " /social-card.png" } = Astro .props ;
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ import { Fullbleed } from "./layout/fullbleed";
44import links from " ../data/links.json" ;
55import { EPSLogo } from " ./logo/eps-logo" ;
66
7- const buildTimestamp = import . meta . env . TIMESTAMP ;
8- const gitVersion = import . meta . env . GIT_VERSION ;
7+ const buildTimestamp = __TIMESTAMP__ ;
8+ const gitVersion = __GIT_VERSION__ ;
99---
1010
1111 <div class =" mt-auto" >
Original file line number Diff line number Diff line change @@ -10,3 +10,6 @@ interface ImportMetaEnv {
1010interface ImportMeta {
1111 readonly env : ImportMetaEnv ;
1212}
13+
14+ declare const __GIT_VERSION__ : string ;
15+ declare const __TIMESTAMP__ : string ;
You can’t perform that action at this time.
0 commit comments