Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test containers before push #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 70 additions & 3 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build 4testing
- name: Build 4load
id: build
run: |
cd .${DOCKER_PATH}
Expand All @@ -63,11 +63,78 @@ jobs:
docker buildx bake -f build.yml \
--set *.args.GIT_BRANCH=${{ matrix.branch }} \
--set *.platform=linux/amd64 \
--push

--load
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
echo "version=${DOCKER_TAG}" >> "$GITHUB_OUTPUT"
shell: bash

- name: Test Container
run: |
cd .${DOCKER_PATH}

NETWORK_NAME="onlyoffice"
NETWORK_EXISTS=$(docker network ls --filter name=$NETWORK_NAME -q)
if [ -z "$NETWORK_EXISTS" ]; then
echo "Creating Docker network: $NETWORK_NAME"
docker network create -d bridge $NETWORK_NAME
else
echo "Docker network $NETWORK_NAME already exists."
fi

services=("db.yml" "elasticsearch.yml" "redis.yml" "rabbitmq.yml" "healthchecks.yml" "migration-runner.yml" "docspace.yml" "notify.yml")

for service in "${services[@]}"; do
sleep 10
DOCKER_TAG=${{ env.DOCKER_TAG }} docker-compose -f "${service}" up -d
done

HAS_ERROR=false
for FILE_NAME in db elasticsearch redis rabbitmq healthchecks migration-runner docspace notify; do
CONTAINER_NAMES=$(docker-compose -f ${FILE_NAME}.yml ps --all | grep onlyoffice | awk '{print $1}')
for CONTAINER_NAME in $CONTAINER_NAMES; do
CONTAINER_STATUS=$(docker inspect -f '{{.State.Status}}' $CONTAINER_NAME)
if [ "$CONTAINER_NAME" == "onlyoffice-migration-runner" ] ; then
if [ "$CONTAINER_STATUS" == "exited" ] ; then
echo "$CONTAINER_NAME container has successfully exited." >> logs.txt
else
echo "Error: $CONTAINER_NAME container is $CONTAINER_STATUS." >> logs.txt
HAS_ERROR=true
fi
else
if [ "$CONTAINER_STATUS" == "running" ] ; then
echo "$CONTAINER_NAME container is running." >> logs.txt
else
echo "Error: $CONTAINER_NAME container is $CONTAINER_STATUS." >> logs.txt
HAS_ERROR=true
fi
fi
done
if [ "$HAS_ERROR" = true ]; then
exit 1
fi
echo "artifactPath=$PWD" >> $GITHUB_ENV
echo "artifactName=${{ matrix.branch }}-logs" | sed 's/\///g' >> $GITHUB_ENV
done
shell: bash

- name: Build 4push
run: |
cd .${DOCKER_PATH}
export DOCKER_TAG=${{ env.DOCKER_TAG }}
images=$(docker images | grep $DOCKER_TAG | awk '{print $1}')
for image in $images
do
full_image_name="$image:$DOCKER_TAG"
echo "Pushing $full_image_name"
docker push $full_image_name
done
shell: bash

- uses: actions/upload-artifact@v3
with:
name: ${{ env.artifactName }}
path: ${{ env.artifactPath }}/logs.txt

- name: Run zap action if needed
if: ${{ github.event.action == 'cron-trigger-action' || github.event_name == 'workflow_dispatch' }}
env:
Expand Down