CI/CD GitHub Actions Automation, Helper Scripts, Container Creation Updates, Bug Fixes, Etc.#8
Conversation
…riable Logic for Services and Custom Services
…pt Updates + Bug Fixes
cmyers-mieweb
left a comment
There was a problem hiding this comment.
Left a couple notes, mostly clarification points or ideas before merge. We can start with these and investigate more further after.
| while [ "$REPOSITORY_BRANCH_EXISTS" != "200" ]; do | ||
| echo "⚠️ The branch you provided, \"$PROJECT_BRANCH\", does not exist on repository at \"$PROJECT_REPOSITORY\"." | ||
| read -p " Enter the project branch to deploy from (leave blank for \"main\") → " PROJECT_BRANCH | ||
| if [ "PROJECT_BRANCH" == "" ]; then |
There was a problem hiding this comment.
This original conditional looks to be making a comparison with a a literal string, perhaps for better accuracy we can check the actual value of the $PROJECT_BRANCH var.
| if [ "PROJECT_BRANCH" == "" ]; then | |
| if [ -z "$PROJECT_BRANCH" ]; then |
There was a problem hiding this comment.
I agree. I will re-factor these comparisons with empty strings to use the empty flag, -z.
|
|
||
| source /root/bin/deployment-scripts/gatherEnvVars.sh # Gather Environment Variables | ||
| gatherSetupCommands "BUILD" "🏗️ Enter the build command (leave blank if no build command) → " # Gather Build Command(s) | ||
| gatherSetupCommands "INSTALL" "📦 Enter the install command (e.g., 'npm install') → " # Gather Install Command(s)echo "$INSTALL_COMMAND" |
There was a problem hiding this comment.
Going to guess that the addition of echo "$INSTALL_COMMAND" is a redundant comment addition? If it is intentional it can be kept, but marking this for script cleanup.
There was a problem hiding this comment.
Correct. It will be removed.
| @@ -0,0 +1,37 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
I wonder with the addition of the user json argument in the container creation process if it will be more efficient to just iterate through port_map.json rather than rely on proxmox tags and checking the pct list which also may include containers with multiple tags? May also reduce this down to 1 or 2 jq commands to just grab the container hostname and user field.
There was a problem hiding this comment.
I like this idea. Prevents having to determine which Hypervisor the container belongs on and using conditional statements. Will refactor.
New re-factored code that checks port-map.json:
CONTAINER_NAME="${CONTAINER_NAME,,}"
CONTAINER_ID=$( { pct list; ssh root@10.15.0.5 'pct list'; } | awk -v name="$CONTAINER_NAME" '$3 == name {print $1}')
if [ -z "$CONTAINER_ID" ]; then
echo "✅ Container with name \"$CONTAINER_NAME\" is available for use."
return 1
fi
CONTAINER_OWNERSHIP=$(ssh root@10.15.20.69 -- "jq '.\"$CONTAINER_NAME\".user' /etc/nginx/port_map.json")
if [ "$TYPE_RUNNER" == "true" ] && (( $CONTAINER_ID % 2 == 0 )); then
PVE1="false"
elif [ "$TYPE_RUNNER" == "true" ] && (( $CONTAINER_ID % 2 != 0 )); then
PVE1="true"
fi
if [ "$CONTAINER_OWNERSHIP" == "null" ]; then
echo "❌ You do not own the container with name \"$CONTAINER_NAME\"."
outputError 1 "You do not own the container with name \"$CONTAINER_NAME\"."
fi|
|
||
| echo "🛎️ Installing Services..." | ||
|
|
||
| # SERVICE_COMMANDS=$(ssh -o SendEnv="LINUX_DISTRIBUTION SERVICES CUSTOM_SERVICES REQUIRE_SERVICES" \ |
There was a problem hiding this comment.
does this commented block have an ongoing purpose in the script? Or was it only used during the development cycle of making this?
There was a problem hiding this comment.
Yes. This block is uncommented now and fully implemented.
* LDAP configuration and prune scripts * proxmox deployment changes * updated container-creation scripts + re-organization * READMEs in each directory, re-organization, updated ci-cd files * READMEs in each directory, re-organization, updated ci-cd files * proxmox launchpad submodule in ci-cd automation * proxmox launchpad submodule * proxmox launchpad submodule
* LDAP configuration and prune scripts * proxmox deployment changes * updated container-creation scripts + re-organization * READMEs in each directory, re-organization, updated ci-cd files * READMEs in each directory, re-organization, updated ci-cd files * proxmox launchpad submodule in ci-cd automation * proxmox launchpad submodule * proxmox launchpad submodule * Updated Root README + LDAP Folder * UPDATED readme
|
I added a README to each folder and edited the existing README at the root directory. I also used AI to create a mermaid graph of how our cluster works at a high level. I thought it did a good job. |
This PR contains all the related scripts for the implementation of the GitHub Actions CI/CD workflow and additions to the automation portion of the create container script.
Brief explanation of each file:
container creation/create-container-sh: Initial script called on the hypervisor to clone a container from a template if needed, install dependencies, public keys, and call deployment scriptscontainer creation/deployOnStart.sh: Helper script used for installing required dependencies into containers, writing environment variables, and any other installation commands to help deploy an application.container creation/get-deployment-details.sh: Script located in Create Container LXC Container and is an extension of the create container script that collects user information about their repository to deploy it.container creation/get-lxc-container-details.sh: Script called when users SSH to create-container@opensource.mieweb.org. Gathers basic information to create a container.container creation/setup-runner.sh: If a user is using Proxmox Launchpad, this script is called to clone a container and install a GitHub runner on it to run future workflows/jobs in the repository.container maintenance/helper-scripts/create-template.sh: If a user is using Proxmox Launchpad for automatic deployment, this script creates a LXC container template for future container clones to speed up the workflow.container maintenance/helper-scripts/delete-runner.sh: If a user is using Proxmox Launchpad, and they delete a branch that is linked to a container, this script will remove the runner associated with that branch/container.container maintenance/helper-scripts/PVE_user_authentication.sh: A script that verifies a user's Proxmox credentials.container maintenance/helper-scripts/verify_container_ownership.sh: Verifies that the container the user is trying to access/modify rightfully belongs to them.container maintenance/check-container-details.sh: Helper script used in Proxmox Launchpad to check if a container needs to be updated, or needs to clone the repository for the first time. This dictates whether to run the container update script or the container creation script.container maintenance/delete-container.sh: Script called from Proxmox Launchpad to begin container/runner deletion process. Since the runner will be offline, it must call the delete-runner.sh.sh in a detached terminal session.container maintenance/start_services.sh: Script that is called from create container to start services on the container and migrate the container if needed.container maintenance/update-container.sh: Script used by Proxmox Launchpad to update containers, fetch new contents, and restart services.