Skip to content

Commit 2a97e29

Browse files
recommit last stable release (for workflow)
1 parent 8a0ee84 commit 2a97e29

1 file changed

Lines changed: 45 additions & 5 deletions

File tree

.github/workflows/godot-ci.yml

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jobs:
8080
uses: actions/checkout@v4
8181
with:
8282
lfs: true
83+
fetch-depth: 0
8384
- name: Setup
8485
run: |
8586
mkdir -v -p ~/.local/share/godot/export_templates/
@@ -98,12 +99,51 @@ jobs:
9899
- name: Install rsync 📚
99100
run: |
100101
apt-get update && apt-get install -y rsync
102+
103+
- name: Git Fetch
104+
run: |
105+
git config --global --add safe.directory "$(pwd)"
106+
git fetch --tags origin
107+
git fetch origin main
108+
101109
- name: Deploy to GitHub Pages 🚀
102-
if: startsWith(github.ref, 'refs/tags/v')
103-
uses: JamesIves/github-pages-deploy-action@releases/v4
110+
if: always()
111+
uses: JamesIves/github-pages-deploy-action@v4
112+
with:
113+
branch: gh-pages
114+
folder: build/web
115+
target-folder: ${{ startsWith(github.ref, 'refs/tags/v') && 'stable' || 'dev' }}
116+
117+
- name: Generate Index Page Metadata
118+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
119+
run: |
120+
# Trust the working directory (avoids "dubious ownership" error)
121+
git config --global --add safe.directory "$(pwd)"
122+
123+
# Fetch all tags and branches
124+
git fetch --tags origin
125+
git fetch origin +refs/heads/*:refs/remotes/origin/*
126+
127+
# Get latest tag
128+
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
129+
130+
# Count commits main is ahead of the latest tag
131+
COMMITS_BEHIND=$(git rev-list --count ${LATEST_TAG}..origin/main)
132+
133+
# Commit dates
134+
DEV_DATE=$(git log -1 --format=%cd origin/main)
135+
STABLE_DATE=$(git log -1 --format=%cd ${LATEST_TAG})
136+
137+
# Generate index.html
138+
mkdir -p deploy-root
139+
echo "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Only One Ladder</title></head><body><h1>Only One Ladder</h1><ul><li><a href='./stable/'>Stable Build</a> - Last updated: ${STABLE_DATE}</li><li><a href='./dev/'>Development Build</a> - Last updated: ${DEV_DATE}</li></ul><p>The development branch is <strong>${COMMITS_BEHIND} commits ahead</strong> of the last stable release (${LATEST_TAG}).</p></body></html>" > deploy-root/index.html
140+
141+
- name: Upload index.html to root of GitHub Pages
142+
uses: JamesIves/github-pages-deploy-action@v4
104143
with:
105-
branch: gh-pages # The branch the action should deploy to.
106-
folder: build/web # The folder the action should deploy.
144+
branch: gh-pages
145+
folder: deploy-root
146+
clean: false
107147

108148
export-mac:
109149
name: Mac Export
@@ -229,4 +269,4 @@ jobs:
229269
dist/mac/*
230270
dist/web.zip
231271
env:
232-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
272+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)