feat: separate CI workflows for building, validating, and publishing Docker images

This commit is contained in:
Juan Sebastián Montoya 2025-11-26 16:03:05 -05:00
parent 94ddf8bde4
commit ce139c48a7
2 changed files with 88 additions and 83 deletions

View file

@ -0,0 +1,53 @@
name: Build and Publish Docker Image
on:
pull_request:
branches:
- main
jobs:
build-and-validate:
name: Build and Validate
runs-on: ubuntu
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate PR Title
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR Title: $PR_TITLE"
# Check if PR title starts with valid prefix
if [[ "$PR_TITLE" =~ ^(Release|Feature|Hotfix|Bugfix)/ ]]; then
echo "✅ PR title is valid: $PR_TITLE"
else
echo "❌ PR title must start with one of: Release/, Feature/, Hotfix/, or Bugfix/"
echo "Current title: $PR_TITLE"
exit 1
fi
- name: Build Docker Image
run: |
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: |
docker run --rm -d --name test-container -p 8080:80 threejs-test:test
sleep 2
curl -f http://localhost:8080 || exit 1
docker stop test-container
- name: Job Summary
if: success()
run: |
SUMMARY_FILE="${FORGEJO_STEP_SUMMARY}"
cat >> "$SUMMARY_FILE" << 'EOF'
## ✅ Build and Validation Complete
- ✅ Docker image built successfully
- ✅ Image validated (container started and HTTP check passed)
The image is ready for deployment.
EOF
cat "$SUMMARY_FILE"