From aeb14921bca7f31374e3d82fc5309793c608a323 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Montoya Date: Wed, 26 Nov 2025 11:03:43 -0500 Subject: [PATCH 1/2] Update Docker image version to 0.1.5 and add VERSION file --- VERSION | 2 ++ portainer.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..ea31cb5 --- /dev/null +++ b/VERSION @@ -0,0 +1,2 @@ +0.1.5 + diff --git a/portainer.yml b/portainer.yml index d7b7c7e..12c072d 100644 --- a/portainer.yml +++ b/portainer.yml @@ -2,7 +2,7 @@ name: threejs-test services: app: - image: git.jusemon.com/jusemon/threejs-test:latest + image: git.jusemon.com/jusemon/threejs-test:0.1.5 pull_policy: build restart: unless-stopped -- 2.49.1 From f3b11c7d63eb87ef6b66f5d38b3304aa867812b6 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Montoya Date: Wed, 26 Nov 2025 11:04:17 -0500 Subject: [PATCH 2/2] Include version info in game --- .forgejo/workflows/ci.yaml | 69 ++++++++++++++++++++++++++++++++++---- Dockerfile | 7 ++++ docker-compose.yml | 8 +++-- index.html | 38 +++++++++++++++++++++ 4 files changed, 114 insertions(+), 8 deletions(-) diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index e87829b..02b041d 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: - name: Build Docker Image run: | - docker build -t threejs-test:test . + docker build --build-arg VERSION=test --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") -t threejs-test:test . - name: Validate Image run: | @@ -82,11 +82,14 @@ jobs: echo "tag=v$NEW_VERSION" >> $GITHUB_OUTPUT echo "Latest tag: $LATEST_TAG" echo "New version: $NEW_VERSION" + echo "Current VERSION file: $(cat VERSION 2>/dev/null || echo 'not found')" - name: Build Docker Image run: | - IMAGE_NAME="git.jusemon.com/jusemon/threejs-test:${{ steps.version.outputs.version }}" - docker build -t "$IMAGE_NAME" . + VERSION="${{ steps.version.outputs.version }}" + BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + IMAGE_NAME="git.jusemon.com/jusemon/threejs-test:$VERSION" + docker build --build-arg VERSION="$VERSION" --build-arg BUILD_DATE="$BUILD_DATE" -t "$IMAGE_NAME" . echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV - name: Push Docker Image @@ -154,6 +157,56 @@ jobs: echo "TAG_CREATED=true" >> $GITHUB_ENV fi + - name: Update Version Files + run: | + VERSION="${{ steps.version.outputs.version }}" + TAG="${{ steps.version.outputs.tag }}" + + echo "📝 Updating version files to: $VERSION" + + # Configure git + git config user.name "forgejo-actions" + git config user.email "forgejo-actions@forgejo.io" + + # Fetch latest changes to avoid conflicts + git fetch origin main || echo "Fetch completed or already up to date" + git checkout main || echo "Already on main" + + # Update VERSION file + echo "$VERSION" > VERSION + + # Update portainer.yml with new version + sed -i "s|\(image: git.jusemon.com/jusemon/threejs-test:\)[0-9.]*|\1$VERSION|" portainer.yml + + # Verify the updates + if grep -q "^$VERSION$" VERSION && grep -q "image: git.jusemon.com/jusemon/threejs-test:$VERSION" portainer.yml; then + echo "✅ Successfully updated VERSION and portainer.yml to $VERSION" + else + echo "❌ Failed to update version files" + exit 1 + fi + + # Check if there are changes to commit + if git diff --quiet VERSION portainer.yml; then + echo "â„šī¸ No changes to commit (files already up to date)" + else + # Stage and commit with [skip ci] to prevent infinite loop + # Note: Forgejo Actions should respect [skip ci] in commit messages + git add VERSION portainer.yml + git commit -m "chore: update version to $VERSION [skip ci]" || { + echo "âš ī¸ Commit failed (may already be committed)" + exit 0 + } + + # Push to main branch + git push origin main || { + echo "âš ī¸ Push failed (may need manual intervention or branch protection)" + exit 0 + } + + echo "✅ Successfully committed and pushed version update to $VERSION" + fi + - name: Job Summary if: success() run: | @@ -183,11 +236,15 @@ jobs: echo "- âš ī¸ Tag \`$TAG\` already exists, skipped creation" >> "$SUMMARY_FILE" fi - cat >> "$SUMMARY_FILE" << 'EOF' + cat >> "$SUMMARY_FILE" << EOF + + ### Version Files + - ✅ VERSION file updated to \`$VERSION\` + - ✅ portainer.yml updated to \`$VERSION\` ### Pull Command - ```bash + \`\`\`bash docker pull git.jusemon.com/jusemon/threejs-test:latest - ``` + \`\`\` EOF diff --git a/Dockerfile b/Dockerfile index 38d09b4..59de9f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,12 @@ FROM nginx:alpine +# Accept build argument for version +ARG VERSION=dev +ARG BUILD_DATE=unknown + +# Create version.json file with build information +RUN printf '{"version":"%s","buildDate":"%s"}\n' "${VERSION}" "${BUILD_DATE}" > /usr/share/nginx/html/version.json + # Copy the HTML file COPY index.html /usr/share/nginx/html/index.html diff --git a/docker-compose.yml b/docker-compose.yml index 747f7dd..7a5b902 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,11 @@ name: threejs-test services: - ui: - build: . + app: + build: + context: . + args: + VERSION: ${VERSION:-dev} + BUILD_DATE: ${BUILD_DATE:-unknown} restart: unless-stopped diff --git a/index.html b/index.html index 9a8bfd3..c509cbe 100644 --- a/index.html +++ b/index.html @@ -72,10 +72,25 @@ text-align: center; text-shadow: 2px 2px 4px rgba(0,0,0,0.5); } + #version { + position: absolute; + top: 20px; + right: 20px; + color: rgba(255, 255, 255, 0.7); + font-size: 14px; + text-shadow: 2px 2px 4px rgba(0,0,0,0.5); + z-index: 100; + font-family: 'Courier New', monospace; + } @media (max-width: 768px) { #instructions { font-size: 14px; } + #version { + font-size: 12px; + top: 10px; + right: 10px; + } } @@ -85,6 +100,8 @@
Health: 100
+
v-
+

Game Over!

Final Score: 0

@@ -97,6 +114,27 @@