Skip to content

Add a CI pipeline to validate elevate with cloudlinux #8

Add a CI pipeline to validate elevate with cloudlinux

Add a CI pipeline to validate elevate with cloudlinux #8

name: "Test Run: centos-7"
on:
push:
branches:
- "main"
- '!docs'
tags-ignore:
- "*"
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-openstack-centos-7
cancel-in-progress: true
env:
TF_VAR_application_credential_id: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
TF_VAR_application_credential_secret: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
TF_VAR_ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
TF_VAR_ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
TF_VAR_os_auth_region: ${{ secrets.OS_AUTH_REGION }}
TF_VAR_os_auth_url: ${{ secrets.OS_AUTH_URL }}
TF_VAR_os_interface: ${{ secrets.OS_INTERFACE }}
TF_VAR_os_project_domain_name: ${{ secrets.OS_PROJECT_DOMAIN_NAME }}
TF_VAR_os_password: ${{ secrets.OS_PASSWORD }}
TF_VAR_os_project_id: ${{ secrets.OS_PROJECT_ID }}
TF_VAR_os_project_domain_id: ${{ secrets.OS_PROJECT_DOMAIN_ID }}
TF_VAR_os_project_name: ${{ secrets.OS_PROJECT_NAME }}
TF_VAR_os_region_name: ${{ secrets.OS_REGION_NAME }}
TF_VAR_os_username: ${{ secrets.OS_USERNAME }}
tf_working_directory: "${{ github.workspace }}/.github/workflows/openstack/centos-7"
jobs:
testsuite:
uses: ./.github/workflows/testsuite.yml
terraform_openstack_create:
needs: [testsuite]
runs-on: self-hosted
defaults:
run:
working-directory: "${{ github.workspace }}/.github/workflows/openstack/centos-7"
steps:
- uses: actions/checkout@v4
- name: Terraform fmt
id: fmt
run: |
terraform fmt -check
continue-on-error: true
- name: Terraform Init
id: init
run: |
terraform init
- name: Terraform Plan
id: plan
run: |
terraform plan -no-color
- name: Terraform Apply
id: apply
run: |
pwd
terraform apply -no-color -auto-approve
mv -v .terraform.lock.hcl terraform.lock.hcl
find $PWD
- name: Upload Terraform State File as Artifact
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-terraform.tfstate
path: "${{ github.workspace }}/.github/workflows/openstack/centos-7"
- name: Terraform Output File Create
run: |
terraform output -json > ${{ github.run_id }}-tf.out.json
- name: Make vm_ip file from Terraform Output File
id: get_vm_ip
run: |
echo "$(jq -r '.address.value' ${{ github.run_id }}-tf.out.json)" > ${{ github.workspace }}/${{ github.run_id }}-vm_ip
- name: Upload VM Output
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/${{ github.run_id }}-vm_ip
overwrite: true
clone_elevate_repo:
runs-on: self-hosted
needs: terraform_openstack_create
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Checkout Repo and Commit
if: github.event_name != 'pull_request'
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
script: |
cd /opt
echo "## [INFO]: ${{ github.ref }}"
echo "## [INFO]: ${{ github.ref_name }}"
echo "## [INFO}: ${{ github.repository }}"
git clone --depth 1 --branch ${{ github.ref_name }} https://github.com/${{ github.repository }}.git
hostname && pwd && ls -la
cd /opt/$(echo ${{ github.repository }} | cut -d / -f2)
git status
- name: Checking out Repo and Pull Request
if: github.event_name == 'pull_request'
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
script: |
cd /opt
echo "[DEBUG]: ${{ github.ref }}"
echo "[DEBUG]: ${{ github.head_ref }}"
echo "## [INFO}: ${{ github.repository }}"
git clone --depth 1 --branch ${{ github.head_ref }} https://github.com/${{ github.repository }}.git
cd /opt/$(echo ${{ github.repository }} | cut -d / -f2)
git status
setup_integration_checks:
runs-on: self-hosted
needs: clone_elevate_repo
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Setup for Integration Checks Prior to Running Elevate
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
script: |
REPODIR=$(echo ${{ github.repository }} | cut -d / -f2)
chmod -v +x /opt/${REPODIR}/t/integration/setup
/opt/${REPODIR}/t/integration/setup
start_elevate:
runs-on: self-hosted
needs: setup_integration_checks
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Starting Elevate
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
timeout: 30m
command_timeout: 30m
script: |
REPODIR=$(echo ${{ github.repository }} | cut -d / -f2)
cp -pv /opt/${REPODIR}/elevate-cpanel /scripts/elevate-cpanel
cp -pv /opt/${REPODIR}/.github/workflows/openstack/status_marker /scripts/status_marker
cp -pv /opt/${REPODIR}/.github/workflows/openstack/reboot_watch /scripts/reboot_watch
chmod -v +x /scripts/elevate-cpanel
until /usr/local/cpanel/cpkeyclt; do echo "Retrying /usr/local/cpanel/cpkeyct until it passes..."; sleep 5; done
/scripts/elevate-cpanel --non-interactive --skip-cpanel-version-check --start &
exit 0
wait_for_stage_1_reboot:
runs-on: self-hosted
needs: start_elevate
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Wait For VM to Come Back From Initial Reboot
working-directory: "./.github/workflows/openstack/"
run: |
./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }}
watch_for_stage_2_reboot:
runs-on: self-hosted
needs: wait_for_stage_1_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Monitor Elevate for Reboot from Stage 1 into Stage 2
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
timeout: 60m
command_timeout: 30m
debug: true
script: |
/scripts/status_marker 1
tail -n40 -F /var/log/elevate-cpanel.log&
sleep .5
REBOOT_STRING="Rebooting into stage 2 of 5" RETVAL=1 /scripts/reboot_watch
wait_for_stage_2_reboot:
runs-on: self-hosted
needs: watch_for_stage_2_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Wait For VM to Come Back From Stage 2 Reboot
working-directory: "./.github/workflows/openstack/"
run: |
./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }}
watch_for_stage_3_reboot:
runs-on: self-hosted
needs: wait_for_stage_2_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Monitor Elevate for Stage 3 Reboot
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
timeout: 60m
command_timeout: 30m
debug: true
script: |
/scripts/status_marker 2
tail -n40 -F /var/log/elevate-cpanel.log&
sleep .5
REBOOT_STRING="Rebooting into stage 3 of 5" RETVAL=1 /scripts/reboot_watch
wait_for_stage_3_reboot:
runs-on: self-hosted
needs: watch_for_stage_3_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Wait For VM to Come Back From Stage 3 Reboot
working-directory: "./.github/workflows/openstack/"
run: |
./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }}
watch_for_stage_4_reboot:
runs-on: self-hosted
needs: wait_for_stage_3_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Monitor Elevate for Stage 4 Reboot
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
timeout: 30m
command_timeout: 30m
script: |
/scripts/status_marker 3
tail -n40 -F /var/log/elevate-cpanel.log&
sleep .5
REBOOT_STRING="Rebooting into stage 4 of 5" RETVAL=1 /scripts/reboot_watch
wait_for_stage_4_reboot:
runs-on: self-hosted
needs: watch_for_stage_4_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Wait For VM to Come Back From Stage 4 Reboot
working-directory: "./.github/workflows/openstack/"
run: |
./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }}
watch_for_stage_5_reboot:
runs-on: self-hosted
needs: wait_for_stage_4_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Monitor Elevate for Stage 5 Reboot
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
timeout: 45m
command_timeout: 35m
script: |
/scripts/status_marker 4
tail -n40 -F /var/log/elevate-cpanel.log&
sleep .5
REBOOT_STRING="Rebooting into stage 5 of 5" RETVAL=1 /scripts/reboot_watch
wait_for_stage_5_reboot:
runs-on: self-hosted
needs: watch_for_stage_5_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Wait For VM to Come Back From Stage 5 Reboot
working-directory: "./.github/workflows/openstack/"
run: |
./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }}
watch_for_final_reboot:
runs-on: self-hosted
needs: wait_for_stage_5_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Monitor Elevate for Final Reboot
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
timeout: 45m
command_timeout: 35m
script: |
/scripts/status_marker 5
tail -n40 -F /var/log/elevate-cpanel.log&
sleep 2.5
SKIP_PID_CHECK=1 REBOOT_STRING="Doing final reboot" RETVAL=1 /scripts/reboot_watch
wait_for_final_reboot:
runs-on: self-hosted
needs: watch_for_final_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Wait For VM to Come Back From Final Reboot
working-directory: "./.github/workflows/openstack/"
run: |
./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }}
verify_upgraded_os:
runs-on: self-hosted
needs: wait_for_final_reboot
outputs:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
steps:
- name: Download VM IP
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-vm_ip
path: ${{ github.workspace }}/
- name: Get VM IP from Artifact
id: VM_IP
run: |
echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT"
cat ${{ github.run_id }}-vm_ip > VM_IP
- name: Export VM_IP to env
env:
VM_IP: ${{ steps.VM_IP.outputs.VM_IP }}
run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}"
- name: Verify End Result Integration Tests
uses: appleboy/[email protected]
with:
host: ${{ steps.VM_IP.outputs.VM_IP }}
username: 'root'
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: '22'
timeout: 5m
command_timeout: 1m
script: |
REPODIR=$(echo ${{ github.repository }} | cut -d / -f2)
/usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/*.t
/usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/centos7-to-almalinux8/*.t
terraform_openstack_destroy:
runs-on: self-hosted
needs: verify_upgraded_os
defaults:
run:
working-directory: "${{ github.workspace }}/.github/workflows/openstack/centos-7"
steps:
- name: Download Terraform State
uses: actions/[email protected]
with:
name: ${{ github.run_id }}-terraform.tfstate
path: "${{ github.workspace }}/.github/workflows/openstack/centos-7/terraform"
- name: Stage Files & Show Artifact Paths
run: |
cd ${{ github.workspace }}/.github/workflows/openstack/centos-7/terraform/
mv -v terraform.lock.hcl .terraform.lock.hcl
find ${{ github.workspace }}/.github/workflows/openstack/centos-7/
- name: Initialize Terraform & Destroy
run: |
cd ${{ github.workspace }}/.github/workflows/openstack/centos-7/terraform/
rm -Rfv .terraform || true
terraform init
terraform destroy -no-color -auto-approve