mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
🚀 add docker test
This commit is contained in:
parent
46cc7c7fc4
commit
a57f2aa21e
19
.github/actions/test-docker/action.yml
vendored
Normal file
19
.github/actions/test-docker/action.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
name: Test Docker Image
|
||||
description: Test the given docker image can run
|
||||
|
||||
inputs:
|
||||
docker-image-name:
|
||||
description: which docker image to test
|
||||
required: true
|
||||
wait-time:
|
||||
description: how many seconds to wait for
|
||||
required: true
|
||||
default: '5'
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: run test
|
||||
run: |
|
||||
${{ github.action_path }}/test_docker.sh ${{ inputs.docker-image-name}} ${{ inputs.wait-time }}
|
||||
shell: bash
|
19
.github/actions/test-docker/test_docker.sh
vendored
Executable file
19
.github/actions/test-docker/test_docker.sh
vendored
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOCKER_IMAGE=$1
|
||||
WAIT_TIME=$2
|
||||
|
||||
docker run --name test-docker-container -d $DOCKER_IMAGE > /dev/null
|
||||
sleep $WAIT_TIME
|
||||
|
||||
CONTAINER_STATE=$(docker ps -f name=test-docker-container -a --format '{{.State}}')
|
||||
if [[ $CONTAINER_STATE = "running" ]]; then
|
||||
echo "container still running, check passed"
|
||||
docker rm -f test-docker-container > /dev/null
|
||||
exit
|
||||
else
|
||||
echo "container exited"
|
||||
docker logs test-docker-container
|
||||
docker rm test-docker-container > /dev/null
|
||||
exit 1
|
||||
fi
|
7
.github/workflows/main.yml
vendored
7
.github/workflows/main.yml
vendored
@ -142,10 +142,17 @@ jobs:
|
||||
context: .
|
||||
file: ./docker/Dockerfile_with_frontend
|
||||
push: false
|
||||
load: true
|
||||
tags: felinae98/nonebot-bison:dummy
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Test image
|
||||
uses: ./.github/actions/test-docker
|
||||
with:
|
||||
docker-image-name: felinae98/nonebot-bison:dummy
|
||||
wait-time: 10
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
|
Loading…
x
Reference in New Issue
Block a user