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 11
11
env :
12
12
PREVIEW_HOSTNAME : ep-preview.click
13
13
GITHUB_BRANCH_NAME : ${{ github.head_ref || github.ref_name }}
14
+ GITHUB_COMMIT_HASH : ${{ github.event.pull_request.head.sha }}
14
15
15
16
steps :
16
17
- name : Checkout
@@ -33,15 +34,12 @@ jobs:
33
34
- name : Install dependencies
34
35
run : make install
35
36
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
-
41
37
- 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
45
43
46
44
- name : Set up SSH key
47
45
uses : webfactory/ssh-agent@v0.9.1
52
50
run : ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts
53
51
54
52
- name : Upload preview
55
- run : make preview BRANCH=$GITHUB_BRANCH_NAME
53
+ env :
54
+ BRANCH : " ${{ env.GITHUB_BRANCH_NAME }}"
55
+ run : make preview
56
56
57
57
- name : Update PR Comment
58
58
uses : actions/github-script@v7
80
80
}
81
81
});
82
82
83
- const branch_name = process.env.BRANCH_NAME ;
83
+ const branch_name = process.env.GITHUB_BRANCH_NAME ;
84
84
const url = "https://" + branch_name + "." + process.env.PREVIEW_HOSTNAME;
85
85
const timestamp = new Date().toISOString();
86
86
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";
13
13
import preload from "astro-preload" ;
14
14
import { execSync } from "node:child_process" ;
15
15
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
+ }
20
29
21
30
// https://astro.build/config
22
31
export default defineConfig ( {
23
32
vite : {
24
33
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 ) ,
30
41
} ,
31
42
resolve : {
32
43
alias : {
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ interface Props {
5
5
image? : string ;
6
6
}
7
7
8
- const buildTimestamp = import . meta . env . TIMESTAMP ;
9
- const gitVersion = import . meta . env . GIT_VERSION ;
8
+ const buildTimestamp = __TIMESTAMP__ ;
9
+ const gitVersion = __GIT_VERSION__ ;
10
10
const canonicalURL = new URL (Astro .url .pathname , Astro .site );
11
11
12
12
const { 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";
4
4
import links from " ../data/links.json" ;
5
5
import { EPSLogo } from " ./logo/eps-logo" ;
6
6
7
- const buildTimestamp = import . meta . env . TIMESTAMP ;
8
- const gitVersion = import . meta . env . GIT_VERSION ;
7
+ const buildTimestamp = __TIMESTAMP__ ;
8
+ const gitVersion = __GIT_VERSION__ ;
9
9
---
10
10
11
11
<div class =" mt-auto" >
Original file line number Diff line number Diff line change @@ -10,3 +10,6 @@ interface ImportMetaEnv {
10
10
interface ImportMeta {
11
11
readonly env : ImportMetaEnv ;
12
12
}
13
+
14
+ declare const __GIT_VERSION__ : string ;
15
+ declare const __TIMESTAMP__ : string ;
You can’t perform that action at this time.
0 commit comments