Update ci-oci-docker-install.yml #29
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: Install OneClickInstall Docker | |
on: | |
push: | |
branches: | |
- feature/oci-docker | |
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 | |
wget https://raw.githubusercontent.com/ONLYOFFICE/DocSpace-buildtools/feature/oci-docker/install/OneClickInstall/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 $? | |
timeout 300 bash -c 'echo -n "Waiting for all containers to start..."; 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" # red | |
echo "container_status=red" >> $GITHUB_ENV ;; | |
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 | |