Skip to content
  • Sponsor GDQuest/learn-gdscript

  • Notifications You must be signed in to change notification settings
  • Fork 182
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7f52a81

Browse files
committedJan 15, 2022
improvement: add build details as JS object
1 parent 3671a28 commit 7f52a81

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed
 

‎.github/workflows/BuildGodot.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ jobs:
5252
- name: Add Git Hash to build
5353
run: |
5454
cd build/web${{inputs.sub_build_path}}
55-
sed -i "s@>branch and commit hash<@>${{ inputs.watermark }}<@" index.html && \
55+
sed -i "s@>branch and commit hash@>${{ inputs.watermark }}<@" index.html && \
56+
sed -i "s@GDQUEST_ENVIRONMENT = {}@GDQUEST_ENVIRONMENT = {github_repository: '$GITHUB_REPOSITORY',github_workflow: '$GITHUB_WORKFLOW',github_ref_name: '$GITHUB_REF_NAME',github_sha: '$GITHUB_SHA',override_file: '${{ override_file }}',sub_build_path: '${{ sub_build_path }}',watermark: '${{ watermark }}'}@" index.html && \
5657
echo "added commit hash to index.html" || echo "failed to add the commit hash"
5758
- name: Upload Artifact
5859
uses: actions/upload-artifact@v1

‎html_export/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<script type="text/javascript" src="$GODOT_URL"></script>
6666
<script type="text/javascript">
6767
const GODOT_CONFIG = $GODOT_CONFIG;
68+
const GDQUEST_ENVIRONMENT = {};
6869
</script>
6970
<script type="text/javascript" src="bootstrap.js"></script>
7071
</html>

‎html_export/static/bootstrap.d.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ interface GDQuestLib {
77
};
88
}
99

10+
interface GDQUEST_ENVIRONMENT {
11+
github_repository: string;
12+
github_workflow: string;
13+
github_ref_name: string;
14+
github_sha: string;
15+
override_file: string;
16+
sub_build_path: string;
17+
watermark: string;
18+
}
19+
1020
interface Signal {
1121
disconnect: (fn: (...args: any[]) => void) => boolean;
1222
connect: (fn: (...args: any[]) => void) => () => boolean;
@@ -47,7 +57,7 @@ declare class GodotEngineInstance {
4757

4858
declare const GODOT_CONFIG: {
4959
canvasResizePolicy: number;
50-
unloadAfterInit: bool;
60+
unloadAfterInit: boolean;
5161
canvas: HTMLCanvasElement;
5262
executable: string;
5363
mainPack: string;
@@ -67,4 +77,5 @@ declare const Engine: {
6777

6878
interface Window {
6979
GDQUEST: GDQuestLib;
80+
GDQUEST_ENVIRONMENT: GDQUEST_ENVIRONMENT;
7081
}

‎html_export/static/bootstrap.js

+17
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ window.GDQUEST = ((/** @type {GDQuestLib} */ GDQUEST) => {
114114
*/
115115
const onPackageLoaded = () => {
116116
displayPercentage(1);
117+
console.log("package loaded");
117118
setTimeout(() => {
118119
setStatusMode(StatusMode.DONE);
119120
is_done = true;
@@ -301,13 +302,29 @@ window.GDQUEST = ((/** @type {GDQuestLib} */ GDQUEST) => {
301302
const { userAgent, vendor } = navigator;
302303
const { width, height } = screen;
303304
const { innerHeight, innerWidth } = window;
305+
const {
306+
github_repository = "",
307+
github_workflow = "",
308+
github_ref_name = "",
309+
github_sha = "",
310+
override_file = "",
311+
sub_build_path = "",
312+
watermark = "",
313+
} = window.GDQUEST_ENVIRONMENT || {};
304314
const data = {
305315
userAgent,
306316
vendor,
307317
width,
308318
height,
309319
innerHeight,
310320
innerWidth,
321+
github_repository,
322+
github_workflow,
323+
github_ref_name,
324+
github_sha,
325+
override_file,
326+
sub_build_path,
327+
watermark,
311328
...additionalData,
312329
};
313330
makeLogFunction(LEVELS.TRACE)(data, `INIT`);

0 commit comments

Comments
 (0)
Failed to load comments.