backend & types
This commit is contained in:
76
.gitea/actions/init-db/action.yaml
Normal file
76
.gitea/actions/init-db/action.yaml
Normal file
@@ -0,0 +1,76 @@
|
||||
name: initialize database
|
||||
description: initialize database by using database of test environment
|
||||
author: BinKrassDuFass
|
||||
|
||||
inputs:
|
||||
MONGODB_SERVICE_NAME:
|
||||
description: 'Name of the MongoDB service'
|
||||
required: true
|
||||
default: 'mongo'
|
||||
|
||||
TIBI_USERNAME:
|
||||
description: 'Username of the Tibi account'
|
||||
required: true
|
||||
default: 'admin'
|
||||
|
||||
TIBI_PASSWORD:
|
||||
description: 'Password of the Tibi account'
|
||||
required: true
|
||||
default: 'admin'
|
||||
|
||||
TIBI_API_URL:
|
||||
description: 'URL of the Tibi API'
|
||||
required: true
|
||||
default: 'http://tibi-server:8080/api/v1'
|
||||
|
||||
TIBI_API_CONFIG_PATH:
|
||||
description: 'Path of the Tibi API config'
|
||||
required: true
|
||||
default: "${{github.workspace}}/api/config.yml}}"
|
||||
|
||||
TIBI_API_NAMESPACE:
|
||||
description: 'Namespace of the Tibi API'
|
||||
required: true
|
||||
|
||||
PROJECT_NAME:
|
||||
description: 'Name of the project'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup mongo tools
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::setup Mongo keys"
|
||||
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
|
||||
sudo apt-get install -y gnupg
|
||||
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
|
||||
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::mongodb tools"
|
||||
sudo apt-get update
|
||||
echo "aptitude install mongodb-database-tools"
|
||||
sudo apt-get install -y mongodb-database-tools
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "mongodump --version"
|
||||
mongodump --version
|
||||
|
||||
- name: Restore MongoDB Data
|
||||
run: |
|
||||
echo "::group::initialize mongo data"
|
||||
mongorestore --uri "mongodb://${{inputs.MONGODB_SERVICE_NAME}}:27017" ./.github/actions/init-db/mongo-dump
|
||||
echo "::endgroup::"
|
||||
shell: bash
|
||||
|
||||
- name: set config in tibi
|
||||
shell: bash
|
||||
run: ./.github/actions/init-db/setConfigInTibiProject.sh ${{inputs.TIBI_USERNAME}} ${{inputs.TIBI_PASSWORD}} ${{inputs.TIBI_API_URL}} ${{inputs.TIBI_API_CONFIG_PATH}} ${{inputs.TIBI_API_NAMESPACE}} ${{inputs.PROJECT_NAME}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
.gitea/actions/init-db/mongo-dump/admin/system.version.bson
Normal file
BIN
.gitea/actions/init-db/mongo-dump/admin/system.version.bson
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"admin.system.version"}],"uuid":"c25383adb2a64a8ca31b3bc5cbcb6690"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"admin.system.version"}],"uuid":"c25383adb2a64a8ca31b3bc5cbcb6690"}
|
||||
BIN
.gitea/actions/init-db/mongo-dump/mongo-dump/tibi/project.bson
Normal file
BIN
.gitea/actions/init-db/mongo-dump/mongo-dump/tibi/project.bson
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi.project"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi.project"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi.project"},{"v":{"$numberInt":"2"},"unique":true,"key":{"name":{"$numberInt":"1"}},"name":"name_1","ns":"tibi.project"},{"v":{"$numberInt":"2"},"key":{"_fts":"text","_ftsx":{"$numberInt":"1"}},"name":"textindex","ns":"tibi.project","weights":{"name":{"$numberInt":"1"}},"default_language":"german","language_override":"language","textIndexVersion":{"$numberInt":"3"}}],"uuid":"a0a6733bdb52400f9f3b17985bc28bcc"}
|
||||
BIN
.gitea/actions/init-db/mongo-dump/mongo-dump/tibi/user.bson
Normal file
BIN
.gitea/actions/init-db/mongo-dump/mongo-dump/tibi/user.bson
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi.user"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi.user"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi.user"},{"v":{"$numberInt":"2"},"unique":true,"key":{"username":{"$numberInt":"1"}},"name":"username_1","ns":"tibi.user"},{"v":{"$numberInt":"2"},"key":{"_fts":"text","_ftsx":{"$numberInt":"1"}},"name":"textindex","ns":"tibi.user","weights":{"$**":{"$numberInt":"1"}},"default_language":"german","language_override":"language","textIndexVersion":{"$numberInt":"3"}}],"uuid":"ba627bbd4ac24b3ca92aebdc33b7d4b0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.backups"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.backups"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.backups"}],"uuid":"4993cf280e844b5b80fe208350713002"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.banner"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.banner"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.banner"}],"uuid":"7346de51448b4a27b289a0e32336d0b6"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.content"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.content"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.content"},{"v":{"$numberInt":"2"},"key":{"meta.datum":{"$numberInt":"1"}},"name":"meta.datum_1","ns":"tibi_allkids_erfurt.content"}],"uuid":"df9951d7cf964e5e8a22360c09aa27c7"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.forms"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.forms"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.forms"}],"uuid":"7815c4dfc9d9460c8aac8cf94cc67ea6"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.lighthouse"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.lighthouse"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.lighthouse"}],"uuid":"fca0bbd4089a43689609593178154de9"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.lighthouseSubpath"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.lighthouseSubpath"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.lighthouseSubpath"}],"uuid":"b72120ec4cd34054a83833dce78c869f"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.navigation"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.navigation"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.navigation"}],"uuid":"d989bd0ea7ba4ea4ae728b8a6baa62ba"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.ssr"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.ssr"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.ssr"},{"v":{"$numberInt":"2"},"unique":true,"key":{"path":{"$numberInt":"1"}},"name":"path_1","ns":"tibi_allkids_erfurt.ssr"}],"uuid":"75869e19f8164beabe53366265b10208"}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.temperature"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.temperature"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.temperature"}],"uuid":"eb60c1bc334c4fa2a473fdb6c99b3e6a"}
|
||||
BIN
.gitea/actions/init-db/mongo-dump/tibi/project.bson
Normal file
BIN
.gitea/actions/init-db/mongo-dump/tibi/project.bson
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi.project"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi.project"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi.project"},{"v":{"$numberInt":"2"},"unique":true,"key":{"name":{"$numberInt":"1"}},"name":"name_1","ns":"tibi.project"},{"v":{"$numberInt":"2"},"key":{"_fts":"text","_ftsx":{"$numberInt":"1"}},"name":"textindex","ns":"tibi.project","weights":{"name":{"$numberInt":"1"}},"default_language":"german","language_override":"language","textIndexVersion":{"$numberInt":"3"}}],"uuid":"a0a6733bdb52400f9f3b17985bc28bcc"}
|
||||
BIN
.gitea/actions/init-db/mongo-dump/tibi/user.bson
Normal file
BIN
.gitea/actions/init-db/mongo-dump/tibi/user.bson
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi.user"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi.user"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi.user"},{"v":{"$numberInt":"2"},"unique":true,"key":{"username":{"$numberInt":"1"}},"name":"username_1","ns":"tibi.user"},{"v":{"$numberInt":"2"},"key":{"_fts":"text","_ftsx":{"$numberInt":"1"}},"name":"textindex","ns":"tibi.user","weights":{"$**":{"$numberInt":"1"}},"default_language":"german","language_override":"language","textIndexVersion":{"$numberInt":"3"}}],"uuid":"ba627bbd4ac24b3ca92aebdc33b7d4b0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.backups"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.backups"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.backups"}],"uuid":"4993cf280e844b5b80fe208350713002"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.banner"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.banner"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.banner"}],"uuid":"7346de51448b4a27b289a0e32336d0b6"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.content"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.content"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.content"},{"v":{"$numberInt":"2"},"key":{"meta.datum":{"$numberInt":"1"}},"name":"meta.datum_1","ns":"tibi_allkids_erfurt.content"}],"uuid":"df9951d7cf964e5e8a22360c09aa27c7"}
|
||||
BIN
.gitea/actions/init-db/mongo-dump/tibi_allkids_erfurt/forms.bson
Normal file
BIN
.gitea/actions/init-db/mongo-dump/tibi_allkids_erfurt/forms.bson
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.forms"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.forms"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.forms"}],"uuid":"7815c4dfc9d9460c8aac8cf94cc67ea6"}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.navigation"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.navigation"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.navigation"}],"uuid":"d989bd0ea7ba4ea4ae728b8a6baa62ba"}
|
||||
BIN
.gitea/actions/init-db/mongo-dump/tibi_allkids_erfurt/ssr.bson
Normal file
BIN
.gitea/actions/init-db/mongo-dump/tibi_allkids_erfurt/ssr.bson
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.ssr"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.ssr"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.ssr"},{"v":{"$numberInt":"2"},"unique":true,"key":{"path":{"$numberInt":"1"}},"name":"path_1","ns":"tibi_allkids_erfurt.ssr"}],"uuid":"75869e19f8164beabe53366265b10208"}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{},"indexes":[{"v":{"$numberInt":"2"},"key":{"_id":{"$numberInt":"1"}},"name":"_id_","ns":"tibi_allkids_erfurt.temperature"},{"v":{"$numberInt":"2"},"key":{"insertTime":{"$numberInt":"1"}},"name":"insertTime_1","ns":"tibi_allkids_erfurt.temperature"},{"v":{"$numberInt":"2"},"key":{"updateTime":{"$numberInt":"1"}},"name":"updateTime_1","ns":"tibi_allkids_erfurt.temperature"}],"uuid":"eb60c1bc334c4fa2a473fdb6c99b3e6a"}
|
||||
108
.gitea/actions/init-db/setConfigInTibiProject.sh
Normal file
108
.gitea/actions/init-db/setConfigInTibiProject.sh
Normal file
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Start a GitHub Actions group for input validation
|
||||
echo "::group::Validating Inputs"
|
||||
|
||||
# Check if the correct number of arguments is passed
|
||||
if [ "$#" -ne 6 ]; then
|
||||
echo "Incorrect number of arguments provided."
|
||||
echo "Usage: $0 <TIBI_USERNAME> <TIBI_PASSWORD> <TIBI_API_URL> <PROJECT_API_CONFIG> <PROJECT_NAMESPACE> <PROJECT_NAME>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Assigning passed arguments to variables for better readability
|
||||
TIBI_USERNAME=$1
|
||||
TIBI_PASSWORD=$2
|
||||
TIBI_API_URL=$3
|
||||
PROJECT_API_CONFIG=$4
|
||||
PROJECT_NAMESPACE=$5
|
||||
PROJECT_NAME=$6
|
||||
|
||||
echo "Provided TIBI_USERNAME: $TIBI_USERNAME"
|
||||
echo "TIBI_API_URL: $TIBI_API_URL"
|
||||
# Be cautious with logging sensitive data like passwords and tokens
|
||||
# Echoing the password or sensitive information is generally not recommended
|
||||
|
||||
# End the input validation group
|
||||
echo "::endgroup::"
|
||||
|
||||
# Start a group for authentication
|
||||
echo "::group::Authenticating User"
|
||||
|
||||
# Prepare authentication request payload
|
||||
auth_payload=$(jq -n --arg username "$TIBI_USERNAME" --arg password "$TIBI_PASSWORD" '{username: $username, password: $password}')
|
||||
echo "Authentication payload: $auth_payload"
|
||||
# Fetch the authentication token
|
||||
echo "Requesting authentication token..."
|
||||
auth_response=$(curl -s -X POST -H "Content-Type: application/json" -d "$auth_payload" "$TIBI_API_URL/login")
|
||||
# Logging the response for debugging (remove sensitive data as necessary)
|
||||
echo "Authentication response: $auth_response"
|
||||
|
||||
# Extract token from the response
|
||||
TIBI_AUTH_TOKEN=$(echo $auth_response | jq -r '.token')
|
||||
|
||||
# Check if the token was successfully retrieved
|
||||
if [ -z "$TIBI_AUTH_TOKEN" ]; then
|
||||
echo "Failed to get authentication token. Exiting script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Authentication token received successfully."
|
||||
echo "::endgroup::"
|
||||
|
||||
# Start a group for fetching project data
|
||||
echo "::group::Fetching Project Data"
|
||||
|
||||
# Get the list of projects from the API
|
||||
echo "Retrieving projects..."
|
||||
response=$(curl -s -H "X-Auth-Token: $TIBI_AUTH_TOKEN" "$TIBI_API_URL/project")
|
||||
echo $response
|
||||
projects=$(echo $response) # Parse the JSON response to get project data
|
||||
|
||||
echo "::endgroup::"
|
||||
|
||||
# Start a group for processing project data
|
||||
echo "::group::Processing Project Data"
|
||||
|
||||
# Initialize variables to track project existence
|
||||
projectFound=false
|
||||
projectId=""
|
||||
|
||||
# Loop through each project to find if the required project exists
|
||||
for row in $(echo "${projects}" | jq -r '.[] | @base64'); do
|
||||
_jq() {
|
||||
echo ${row} | base64 --decode | jq -r ${1}
|
||||
}
|
||||
|
||||
api_name=$(_jq '.name')
|
||||
# Check if the current project's namespace matches the target
|
||||
if [ "$api_name" == "$PROJECT_NAME" ]; then
|
||||
projectId=$(_jq '.id')
|
||||
projectData=$(echo ${row} | base64 --decode)
|
||||
projectFound=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "::endgroup::"
|
||||
|
||||
# Start a group for creating or updating the project
|
||||
echo "::group::Creating or Updating Project"
|
||||
|
||||
# Conditionally create a new project or update the existing one
|
||||
if [ "$projectFound" = true ]; then
|
||||
echo "Project found with ID: $projectId, updating..."
|
||||
# Prepare updated project data
|
||||
updatedProjectData=$(echo $projectData | jq --arg configFile "$PROJECT_API_CONFIG" '.configFile = $configFile | del(.id)')
|
||||
# Send a PUT request to update the project
|
||||
updateResponse=$(curl -s -X PUT -H "Content-Type: application/json" -H "X-Auth-Token: $TIBI_AUTH_TOKEN" -d "$updatedProjectData" "$TIBI_API_URL/project/$projectId")
|
||||
# Logging the response for debugging (remove sensitive data as necessary)
|
||||
echo "Update response: $updateResponse"
|
||||
|
||||
else
|
||||
echo "Project not found. Creating new project..."
|
||||
# Send a POST request to create a new project
|
||||
createResponse=$(curl -s -X POST -H "Content-Type: application/json" -H "X-Auth-Token: $TIBI_AUTH_TOKEN" -d "{\"configFile\":\"$PROJECT_API_CONFIG\", \"name\":\"$PROJECT_NAMESPACE\", \"namespace\":\"$PROJECT_NAMESPACE\", \"description\":\"$PROJECT_NAMESPACE\"}" "$TIBI_API_URL/project")
|
||||
fi
|
||||
|
||||
echo "::endgroup::"
|
||||
Reference in New Issue
Block a user