Merge pull request 'Feature/Deploy improvements' (#2) from Feature/Deploy-improvements into main

Reviewed-on: #2
This commit is contained in:
Juan Sebastián Montoya 2026-01-06 14:53:47 -05:00
commit e87b2688fb
3 changed files with 35 additions and 13 deletions

View file

@ -19,6 +19,6 @@ docker pull {{IMAGE_NAME}}
The image is also available as `latest`: The image is also available as `latest`:
``` ```
docker pull git.jusemon.com/jusemon/threejs-test:latest docker pull {{IMAGE_BASE}}:latest
``` ```

View file

@ -5,6 +5,10 @@ on:
branches: branches:
- main - main
env:
REGISTRY: git.jusemon.com
IMAGE_BASE: git.jusemon.com/${{ github.repository }}
jobs: jobs:
publish: publish:
name: Publish to Registry name: Publish to Registry
@ -18,7 +22,7 @@ jobs:
- name: Login to Registry - name: Login to Registry
run: | run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.jusemon.com -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Determine Version - name: Determine Version
id: version id: version
@ -120,17 +124,21 @@ jobs:
git fetch origin main || echo "Fetch completed or already up to date" git fetch origin main || echo "Fetch completed or already up to date"
git checkout main || echo "Already on main" git checkout main || echo "Already on main"
# Update version in files
IMAGE_BASE="${{ env.IMAGE_BASE }}"
# Update VERSION file # Update VERSION file
echo "$VERSION" > VERSION echo "$VERSION" > VERSION
# Update portainer.yml with new version # Update portainer.yml with new version
sed -i "s|\(image: git.jusemon.com/jusemon/threejs-test:\)[0-9.]*|\1$VERSION|" portainer.yml # Using a generic match for the image line to be robust against name changes
sed -i "s|image: .*|image: $IMAGE_BASE:$VERSION|g" portainer.yml
# Verify the updates # Verify the updates
if grep -q "^$VERSION$" VERSION && grep -q "image: git.jusemon.com/jusemon/threejs-test:$VERSION" portainer.yml; then if grep -q "^$VERSION$" VERSION && grep -q "image: $IMAGE_BASE:$VERSION" portainer.yml; then
echo "✅ Successfully updated VERSION and portainer.yml to $VERSION" echo "✅ Successfully updated VERSION and portainer.yml to $VERSION"
else else
echo "❌ Failed to update version files" echo "❌ Failed to update version files (Expected Image: $IMAGE_BASE:$VERSION)"
exit 1 exit 1
fi fi
@ -163,25 +171,25 @@ jobs:
run: | run: |
VERSION="${{ steps.version.outputs.version }}" VERSION="${{ steps.version.outputs.version }}"
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
IMAGE_NAME="git.jusemon.com/jusemon/threejs-test:$VERSION" IMAGE_NAME="${{ env.IMAGE_BASE }}:$VERSION"
docker build --build-arg VERSION="$VERSION" --build-arg BUILD_DATE="$BUILD_DATE" -t "$IMAGE_NAME" . docker build --build-arg VERSION="$VERSION" --build-arg BUILD_DATE="$BUILD_DATE" -t "$IMAGE_NAME" .
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
- name: Push Docker Image - name: Push Docker Image
run: | run: |
IMAGE_NAME="git.jusemon.com/jusemon/threejs-test:${{ steps.version.outputs.version }}" IMAGE_NAME="${{ env.IMAGE_BASE }}:${{ steps.version.outputs.version }}"
docker push "$IMAGE_NAME" docker push "$IMAGE_NAME"
# Also tag as 'latest' for main branch # Also tag as 'latest' for main branch
docker tag "$IMAGE_NAME" "git.jusemon.com/jusemon/threejs-test:latest" docker tag "$IMAGE_NAME" "${{ env.IMAGE_BASE }}:latest"
docker push "git.jusemon.com/jusemon/threejs-test:latest" docker push "${{ env.IMAGE_BASE }}:latest"
- name: Generate Release Notes - name: Generate Release Notes
id: release_notes id: release_notes
run: | run: |
VERSION="${{ steps.version.outputs.version }}" VERSION="${{ steps.version.outputs.version }}"
TAG="${{ steps.version.outputs.tag }}" TAG="${{ steps.version.outputs.tag }}"
IMAGE_NAME="git.jusemon.com/jusemon/threejs-test:$VERSION" IMAGE_NAME="${{ env.IMAGE_BASE }}:$VERSION"
# Use the version update commit hash (which has the correct version in files) # Use the version update commit hash (which has the correct version in files)
COMMIT_HASH="${VERSION_COMMIT_HASH:-$(git rev-parse HEAD)}" COMMIT_HASH="${VERSION_COMMIT_HASH:-$(git rev-parse HEAD)}"
COMMIT_SHORT=$(git rev-parse --short "$COMMIT_HASH") COMMIT_SHORT=$(git rev-parse --short "$COMMIT_HASH")
@ -210,9 +218,11 @@ jobs:
# Replace placeholders in template # Replace placeholders in template
# Handle COMMITS separately due to multi-line content that can break sed # Handle COMMITS separately due to multi-line content that can break sed
IMAGE_BASE="${{ env.IMAGE_BASE }}"
# First, replace all single-line placeholders # First, replace all single-line placeholders
sed -e "s|{{VERSION}}|$VERSION|g" \ sed -e "s|{{VERSION}}|$VERSION|g" \
-e "s|{{IMAGE_NAME}}|$IMAGE_NAME|g" \ -e "s|{{IMAGE_NAME}}|$IMAGE_NAME|g" \
-e "s|{{IMAGE_BASE}}|$IMAGE_BASE|g" \
-e "s|{{COMMIT_HASH}}|$COMMIT_HASH|g" \ -e "s|{{COMMIT_HASH}}|$COMMIT_HASH|g" \
-e "s|{{COMMIT_SHORT}}|$COMMIT_SHORT|g" \ -e "s|{{COMMIT_SHORT}}|$COMMIT_SHORT|g" \
-e "s|{{BUILD_DATE}}|$BUILD_DATE|g" \ -e "s|{{BUILD_DATE}}|$BUILD_DATE|g" \
@ -264,7 +274,8 @@ jobs:
SUMMARY_FILE="${FORGEJO_STEP_SUMMARY:-/dev/stdout}" SUMMARY_FILE="${FORGEJO_STEP_SUMMARY:-/dev/stdout}"
VERSION="${{ steps.version.outputs.version }}" VERSION="${{ steps.version.outputs.version }}"
TAG="${{ steps.version.outputs.tag }}" TAG="${{ steps.version.outputs.tag }}"
IMAGE_NAME="git.jusemon.com/jusemon/threejs-test:$VERSION" IMAGE_BASE="${{ env.IMAGE_BASE }}"
IMAGE_NAME="$IMAGE_BASE:$VERSION"
TAG_STATUS="${TAG_CREATED:-false}" TAG_STATUS="${TAG_CREATED:-false}"
cat >> "$SUMMARY_FILE" << EOF cat >> "$SUMMARY_FILE" << EOF
@ -276,7 +287,7 @@ jobs:
### Published Images ### Published Images
- ✅ \`$IMAGE_NAME\` - ✅ \`$IMAGE_NAME\`
- ✅ \`git.jusemon.com/jusemon/threejs-test:latest\` - ✅ \`$IMAGE_BASE:latest\`
### Git Tag ### Git Tag
EOF EOF
@ -295,7 +306,7 @@ jobs:
### Pull Command ### Pull Command
\`\`\`bash \`\`\`bash
docker pull git.jusemon.com/jusemon/threejs-test:latest docker pull ${{ env.IMAGE_BASE }}:latest
\`\`\` \`\`\`
EOF EOF
cat "$SUMMARY_FILE" cat "$SUMMARY_FILE"

11
portainer.yml Normal file
View file

@ -0,0 +1,11 @@
name: slime
services:
app:
image: git.jusemon.com/jusemon/slime:0.1.0
restart: unless-stopped
networks:
default:
name: default-network
external: true