52 lines
1.6 KiB
YAML
52 lines
1.6 KiB
YAML
name: Container Image Build Test for PRs
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
if: github.event.pull_request.draft == false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Container Run
|
|
run: |
|
|
./run-platform.sh -b
|
|
sleep 30
|
|
docker compose -f docker/docker-compose.yaml ps -a
|
|
# Get the names of exited containers
|
|
custom_format="{{.Name}}\t{{.Image}}\t{{.Service}}"
|
|
EXITED_CONTAINERS=$(docker compose -f docker/docker-compose.yaml ps -a --filter status=exited --format "$custom_format")
|
|
|
|
line_count=$(echo "$EXITED_CONTAINERS" | wc -l)
|
|
|
|
if [ "$line_count" -gt 1 ]; then
|
|
echo "Exited Containers: $EXITED_CONTAINERS"
|
|
|
|
SERVICE=$(echo "$EXITED_CONTAINERS" | awk 'NR>0 {print $3}')
|
|
echo "Exited Services:"
|
|
echo "$SERVICE"
|
|
echo "There are exited containers."
|
|
# Print logs of exited containers
|
|
IFS=$'\n'
|
|
for SERVICE in $SERVICE; do
|
|
docker compose -f docker/docker-compose.yaml logs "$SERVICE"
|
|
done
|
|
docker compose -f docker/docker-compose.yaml down -v
|
|
exit 1
|
|
fi
|
|
docker compose -f docker/docker-compose.yaml down -v
|