Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish to GitHub Pages #5

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

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

# Substitute project version when publishing
/project.godot export-subst
83 changes: 83 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: "Publish to GitHub Pages"
on:
workflow_dispatch:
release:
types:
- published

permissions:
contents: read
pages: write
id-token: write

env:
GODOT_VERSION: 4.3

jobs:
check:
name: Check if GitHub Pages is enabled
runs-on: ubuntu-latest
steps:
- name: Check
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh api "repos/${{ github.repository }}/pages" | jq --exit-status '.build_type == "workflow"'
then
echo "enabled=true" >> "$GITHUB_OUTPUT"
else
echo "# Not published to GitHub Pages" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo -n "Check that Pages is enabled, with the source set to GitHub Actions, in the " >> "$GITHUB_STEP_SUMMARY"
echo "[repository settings](https://github.com/${{ github.repository }}/settings/pages)." >> "$GITHUB_STEP_SUMMARY"
fi
outputs:
enabled: ${{ steps.check.outputs.enabled }}

build:
name: Build for web
needs:
- check
if: ${{ needs.check.outputs.enabled }}
runs-on: ubuntu-latest
container:
image: barichello/godot-ci:4.3
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true

- name: Set up export templates
run: |
mkdir -v -p ~/.local/share/godot/export_templates/
mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable

- name: Web Build
run: |
mkdir -v -p build/web
godot --headless --verbose --export-release "Web" ./build/web/index.html

- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
name: web
path: build/web

publish:
name: Publish to GitHub Pages
needs:
- build
runs-on: ubuntu-latest
steps:
- id: deploy
name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
with:
artifact_name: web

- name: Show URL in summary
if: ${{ steps.deploy.outcome == 'success' }}
run: |
echo "Game published to: <${{ steps.deploy.outputs.page_url }}>" >> "$GITHUB_STEP_SUMMARY"
41 changes: 41 additions & 0 deletions export_presets.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[preset.0]

name="Web"
platform="Web"
runnable=false
advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_export_mode=2

[preset.0.options]

custom_template/debug=""
custom_template/release=""
variant/extensions_support=false
variant/thread_support=false
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/export_icon=true
html/custom_html_shell=""
html/head_include=""
html/canvas_resize_policy=2
html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
progressive_web_app/ensure_cross_origin_isolation_headers=true
progressive_web_app/offline_page=""
progressive_web_app/display=1
progressive_web_app/orientation=0
progressive_web_app/icon_144x144=""
progressive_web_app/icon_180x180=""
progressive_web_app/icon_512x512=""
progressive_web_app/background_color=Color(0, 0, 0, 1)