69 lines
2.8 KiB
YAML
69 lines
2.8 KiB
YAML
name: Install OneClickInstall Docker
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, reopened, synchronize]
|
|
paths:
|
|
- '.github/workflows/ci-oci-docker-install.yml'
|
|
- 'install/OneClickInstall/install-Docker.sh'
|
|
workflow_dispatch:
|
|
inputs:
|
|
script-branch:
|
|
description: 'Branch for OCI script docker'
|
|
required: true
|
|
type: string
|
|
default: master
|
|
|
|
jobs:
|
|
Install-OneClickInstall-Docker:
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Test OCI docker scripts
|
|
run: |
|
|
sudo docker image prune --all --force
|
|
|
|
BRANCH_NAME=$(
|
|
case "${{ github.event_name }}" in
|
|
pull_request) echo "${{ github.event.pull_request.head.ref }}";;
|
|
workflow_dispatch) echo "${{ github.event.inputs.script-branch }}";;
|
|
push) echo "${GITHUB_REF#refs/heads/}";;
|
|
esac
|
|
)
|
|
|
|
wget https://download.onlyoffice.com/docspace/docspace-install.sh
|
|
sed '/bash install-Docker.sh/i sed -i "1i set -x" install-Docker.sh' -i docspace-install.sh
|
|
sudo bash docspace-install.sh docker -skiphc true -noni true $([ $BRANCH_NAME != "master" ] && echo "-gb $BRANCH_NAME -s 4testing-") || exit $?
|
|
|
|
echo -n "Waiting for all containers to start..."
|
|
timeout 300 bash -c 'while docker ps | grep -q "starting"; do sleep 5; done' && echo "OK" || echo "container_status=timeout" >> $GITHUB_ENV
|
|
|
|
- name: Check container status
|
|
run: |
|
|
docker ps --all --format "{{.Names}}" | xargs -I {} sh -c '
|
|
status=$(docker inspect --format="{{if .State.Health}}{{.State.Health.Status}}{{else}}no healthcheck{{end}}" {});
|
|
case "$status" in
|
|
healthy) color="\033[0;32m" ;; # green
|
|
"no healthcheck") color="\033[0;33m" ;; # yellow
|
|
*) color="\033[0;31m"; echo "container_status=red" >> $GITHUB_ENV ;; # red
|
|
esac;
|
|
printf "%-30s ${color}%s\033[0m\n" "{}:" "$status";
|
|
'
|
|
|
|
- name: Print logs for crashed container
|
|
run: |
|
|
docker ps --all --format "{{.Names}}" | xargs -I {} sh -c '
|
|
status=$(docker inspect --format="{{if .State.Health}}{{.State.Health.Status}}{{else}}no healthcheck{{end}}" {});
|
|
case "$status" in
|
|
healthy | "no healthcheck") ;;
|
|
*)
|
|
echo "Logs for container {}:";
|
|
docker logs --tail 30 {} | sed "s/^/\t/g";
|
|
;;
|
|
esac;
|
|
'
|
|
case "${{ env.container_status }}" in
|
|
timeout) echo "Timeout reached. Not all containers are running."; exit 1 ;;
|
|
red) echo "One or more containers have status 'red'. Job will fail."; exit 1 ;;
|
|
esac
|
|
|