Enhance OpenAPI docs #73
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build the Docker image | |
run: docker build . --file Dockerfile --tag grandnode2:pr-latest | |
- name: Start MongoDB container | |
run: | | |
docker run --name mongodb-container -d -p 27017:27017 mongo:latest | |
- name: Wait for MongoDB to be ready | |
run: | | |
echo "Waiting for MongoDB to start..." | |
for i in {1..10}; do | |
nc -z localhost 27017 && echo "MongoDB is up" && break | |
echo "Retrying in 3 seconds..." | |
sleep 3 | |
done | |
- name: List Docker images | |
run: docker images | |
- name: Run the application container | |
run: | | |
docker run --name grandnode2-container -d -p 8080:8080 --link mongodb-container:mongo grandnode2:pr-latest | |
- name: Wait for the application to be ready | |
run: | | |
echo "Waiting for the application to start..." | |
for i in {1..10}; do | |
curl -s http://localhost:8080 && echo "Application is up!" && break | |
echo "Retrying in 3 seconds..." | |
sleep 3 | |
done | |
- name: Trigger the installer via POST request | |
run: | | |
echo "Running installation with form-data..." | |
curl -X POST http://localhost:8080/install \ | |
-H "Content-Type: multipart/form-data" \ | |
-F "[email protected]" \ | |
-F "AdminPassword=SecurePassword123" \ | |
-F "ConfirmPassword=SecurePassword123" \ | |
-F "DataProvider=0" \ | |
-F "MongoDBServerName=mongo" \ | |
-F "MongoDBDatabaseName=grandnode" \ | |
-F "InstallSampleData=true" \ | |
-F "CompanyName=My Company" \ | |
-F "CompanyAddress=123 Main St" \ | |
-F "CompanyPhoneNumber=1234567890" \ | |
-F "[email protected]" | |
- name: Restart the application container | |
run: | | |
docker restart grandnode2-container | |
- name: Test HTTP response after installation | |
run: | | |
echo "Waiting for the application to start..." | |
for i in {1..10}; do | |
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 || echo "error") | |
if [ "$RESPONSE" = "200" ]; then | |
echo "Application is up with HTTP 200 response!" | |
exit 0 | |
elif [ "$RESPONSE" = "error" ]; then | |
echo "Curl encountered an error. Retrying in 3 seconds..." | |
else | |
echo "Received HTTP response code: $RESPONSE. Retrying in 3 seconds..." | |
fi | |
sleep 3 | |
done | |
echo "Application did not start successfully. Final response code: $RESPONSE" | |
exit 1 | |
- name: Stop and remove the container | |
run: | | |
docker stop grandnode2-container | |
docker rm grandnode2-container |