|
1 | 1 | name: "Publish to GitHub Pages" |
2 | 2 | on: |
| 3 | + delete: |
3 | 4 | workflow_dispatch: |
4 | | - release: |
| 5 | + workflow_run: |
| 6 | + workflows: |
| 7 | + - "Build and Export Game" |
5 | 8 | types: |
6 | | - - published |
| 9 | + - completed |
7 | 10 |
|
8 | | -# Cancel any ongoing previous run if the job is re-triggered |
9 | 11 | concurrency: |
10 | 12 | group: ${{ github.workflow }} |
11 | | - cancel-in-progress: true |
12 | 13 |
|
13 | 14 | permissions: |
14 | 15 | contents: read |
15 | 16 | pages: write |
16 | 17 | id-token: write |
17 | 18 |
|
18 | | -env: |
19 | | - GODOT_VERSION: 4.4 |
20 | | - |
21 | 19 | jobs: |
22 | | - check: |
23 | | - name: Check if GitHub Pages is enabled |
24 | | - runs-on: ubuntu-latest |
25 | | - steps: |
26 | | - - name: Check |
27 | | - id: check |
28 | | - env: |
29 | | - GH_TOKEN: ${{ github.token }} |
30 | | - run: | |
31 | | - if gh api "repos/${{ github.repository }}/pages" | jq --exit-status '.build_type == "workflow"' |
32 | | - then |
33 | | - echo "enabled=true" >> "$GITHUB_OUTPUT" |
34 | | - else |
35 | | - echo "# Not published to GitHub Pages" >> "$GITHUB_STEP_SUMMARY" |
36 | | - echo "" >> "$GITHUB_STEP_SUMMARY" |
37 | | - echo -n "Check that Pages is enabled, with the source set to GitHub Actions, in the " >> "$GITHUB_STEP_SUMMARY" |
38 | | - echo "[repository settings](https://github.com/${{ github.repository }}/settings/pages)." >> "$GITHUB_STEP_SUMMARY" |
39 | | - fi |
40 | | - outputs: |
41 | | - enabled: ${{ steps.check.outputs.enabled }} |
42 | | - |
43 | | - build: |
44 | | - name: Build for web |
45 | | - needs: |
46 | | - - check |
47 | | - if: ${{ needs.check.outputs.enabled }} |
48 | | - runs-on: ubuntu-latest |
49 | | - steps: |
50 | | - - name: Checkout |
51 | | - uses: actions/checkout@v4 |
52 | | - with: |
53 | | - lfs: true |
54 | | - |
55 | | - - name: Cache Godot Engine downloads |
56 | | - id: cache-godot |
57 | | - uses: actions/cache@v4 |
58 | | - with: |
59 | | - path: | |
60 | | - build/godot |
61 | | - build/._sc_ |
62 | | - build/editor_data/export_templates/${{ env.GODOT_VERSION }}.stable |
63 | | - key: godot-${{ env.GODOT_VERSION }} |
64 | | - |
65 | | - - name: Download Godot Engine from GitHub release |
66 | | - id: download |
67 | | - if: steps.cache-godot.outputs.cache-hit != 'true' |
68 | | - run: | |
69 | | - mkdir -p build && cd build |
70 | | -
|
71 | | - # Download Godot Engine itself |
72 | | - wget https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip && \ |
73 | | - unzip Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip && \ |
74 | | - mv Godot_v${GODOT_VERSION}-stable_linux.x86_64 godot |
75 | | -
|
76 | | - # Download export templates |
77 | | - mkdir -p editor_data/export_templates |
78 | | - wget https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_export_templates.tpz && \ |
79 | | - unzip Godot_v${GODOT_VERSION}-stable_export_templates.tpz && \ |
80 | | - mv templates editor_data/export_templates/${GODOT_VERSION}.stable |
81 | | -
|
82 | | - # Tell Godot Engine to run in "self-contained" mode so it looks for |
83 | | - # templates here instead of in ~/.local/share/godot/ |
84 | | - touch ._sc_ |
85 | | -
|
86 | | - - name: Web Build |
87 | | - run: | |
88 | | - mkdir -v -p build/web && cd build |
89 | | -
|
90 | | - # Note that the export path can be confusing; it's relative to the |
91 | | - # Godot project path, NOT necessarily the current directory or Godot |
92 | | - # binary location |
93 | | - ./godot --headless --verbose --path ../ --export-release "Web" ./build/web/index.html |
94 | | -
|
95 | | - - name: Upload Artifact |
96 | | - uses: actions/upload-pages-artifact@v3 |
97 | | - with: |
98 | | - name: web |
99 | | - path: build/web |
100 | | - |
101 | 20 | publish: |
102 | | - name: Publish to GitHub Pages |
103 | | - needs: |
104 | | - - build |
| 21 | + name: Publish all branches to GitHub Pages |
105 | 22 | runs-on: ubuntu-latest |
106 | 23 | steps: |
107 | | - - id: deploy |
108 | | - name: Deploy to GitHub Pages |
109 | | - uses: actions/deploy-pages@v4 |
| 24 | + - uses: endlessm/amalgamate-pages@v1 |
110 | 25 | with: |
| 26 | + workflow_name: "Build and Export Game" |
111 | 27 | artifact_name: web |
112 | | - |
113 | | - - name: Show URL in summary |
114 | | - if: ${{ steps.deploy.outcome == 'success' }} |
115 | | - run: | |
116 | | - echo "Game published to: <${{ steps.deploy.outputs.page_url }}>" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments