Skip to content

Commit ec93856

Browse files
authored
Merge pull request #20 from endlessm/T35699-publish-to-github-pages
Publish to GitHub pages
2 parents af353e1 + 9dadf1e commit ec93856

File tree

4 files changed

+135
-3
lines changed

4 files changed

+135
-3
lines changed

.gitattributes

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# Normalize EOL for all files that Git considers text files.
22
* text=auto eol=lf
33

4-
# Exclude GitHub Actions-related files from published asset
5-
/.github export-ignore
6-
/asset-template.json.hb export-ignore
4+
# Exclude GitHub Actions-related files from published asset, except the GitHub
5+
# Pages workflow which learners may find useful to publish their modified game.
6+
/.github/** export-ignore
7+
/.github/workflows !export-ignore
8+
/.github/workflows/** export-ignore
9+
/.github/workflows/githuh-pages.yml !export-ignore
10+
/asset-template.json.hb export-ignore
711

812
# Exclude artwork sources
913
/asset-sources export-ignore
14+
15+
# Substitute project version when publishing
16+
/project.godot export-subst

.github/workflows/github-pages.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "Publish to GitHub Pages"
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types:
6+
- published
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
env:
14+
GODOT_VERSION: 4.3
15+
16+
jobs:
17+
check:
18+
name: Check if GitHub Pages is enabled
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check
22+
id: check
23+
env:
24+
GH_TOKEN: ${{ github.token }}
25+
run: |
26+
if gh api "repos/${{ github.repository }}/pages" | jq --exit-status '.build_type == "workflow"'
27+
then
28+
echo "enabled=true" >> "$GITHUB_OUTPUT"
29+
else
30+
echo "# Not published to GitHub Pages" >> "$GITHUB_STEP_SUMMARY"
31+
echo "" >> "$GITHUB_STEP_SUMMARY"
32+
echo -n "Check that Pages is enabled, with the source set to GitHub Actions, in the " >> "$GITHUB_STEP_SUMMARY"
33+
echo "[repository settings](https://github.com/${{ github.repository }}/settings/pages)." >> "$GITHUB_STEP_SUMMARY"
34+
fi
35+
outputs:
36+
enabled: ${{ steps.check.outputs.enabled }}
37+
38+
build:
39+
name: Build for web
40+
needs:
41+
- check
42+
if: ${{ needs.check.outputs.enabled }}
43+
runs-on: ubuntu-latest
44+
container:
45+
image: barichello/godot-ci:4.3
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
with:
50+
lfs: true
51+
52+
- name: Set up export templates
53+
run: |
54+
mkdir -v -p ~/.local/share/godot/export_templates/
55+
mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
56+
57+
- name: Web Build
58+
run: |
59+
mkdir -v -p build/web
60+
godot --headless --verbose --export-release "Web" ./build/web/index.html
61+
62+
- name: Upload Artifact
63+
uses: actions/upload-pages-artifact@v3
64+
with:
65+
name: web
66+
path: build/web
67+
68+
publish:
69+
name: Publish to GitHub Pages
70+
needs:
71+
- build
72+
runs-on: ubuntu-latest
73+
steps:
74+
- id: deploy
75+
name: Deploy to GitHub Pages
76+
uses: actions/deploy-pages@v4
77+
with:
78+
artifact_name: web
79+
80+
- name: Show URL in summary
81+
if: ${{ steps.deploy.outcome == 'success' }}
82+
run: |
83+
echo "Game published to: <${{ steps.deploy.outputs.page_url }}>" >> "$GITHUB_STEP_SUMMARY"

export_presets.cfg

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[preset.0]
2+
3+
name="Web"
4+
platform="Web"
5+
runnable=false
6+
advanced_options=false
7+
dedicated_server=false
8+
custom_features=""
9+
export_filter="all_resources"
10+
include_filter=""
11+
exclude_filter=""
12+
export_path=""
13+
encryption_include_filters=""
14+
encryption_exclude_filters=""
15+
encrypt_pck=false
16+
encrypt_directory=false
17+
script_export_mode=2
18+
19+
[preset.0.options]
20+
21+
custom_template/debug=""
22+
custom_template/release=""
23+
variant/extensions_support=false
24+
variant/thread_support=false
25+
vram_texture_compression/for_desktop=true
26+
vram_texture_compression/for_mobile=false
27+
html/export_icon=true
28+
html/custom_html_shell=""
29+
html/head_include=""
30+
html/canvas_resize_policy=2
31+
html/focus_canvas_on_start=true
32+
html/experimental_virtual_keyboard=false
33+
progressive_web_app/enabled=false
34+
progressive_web_app/ensure_cross_origin_isolation_headers=true
35+
progressive_web_app/offline_page=""
36+
progressive_web_app/display=1
37+
progressive_web_app/orientation=0
38+
progressive_web_app/icon_144x144=""
39+
progressive_web_app/icon_180x180=""
40+
progressive_web_app/icon_512x512=""
41+
progressive_web_app/background_color=Color(0, 0, 0, 1)

project.godot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ config_version=5
1111
[application]
1212

1313
config/name="blockcoding minigames"
14+
config/version="$Format:%(describe:tags)$"
1415
run/main_scene="res://main-menu/main.tscn"
1516
config/features=PackedStringArray("4.3", "GL Compatibility")
1617
config/icon="res://icon.svg"

0 commit comments

Comments
 (0)