mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-23 17:31:11 +01:00
ci: optimized workflows
This commit is contained in:
76
.github/workflows/docker-crawlab.yml
vendored
76
.github/workflows/docker-crawlab.yml
vendored
@@ -17,6 +17,7 @@ env:
|
||||
IMAGE_NAME_CRAWLAB: crawlabteam/crawlab
|
||||
IMAGE_NAME_CRAWLAB_BACKEND: crawlabteam/crawlab-backend
|
||||
IMAGE_NAME_CRAWLAB_FRONTEND: crawlabteam/crawlab-frontend
|
||||
IMAGE_NAME_CRAWLAB_TENCENT: ccr.ccs.tencentyun.com/crawlabteam/crawlab
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
@@ -131,6 +132,8 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
needs: [ setup, build-backend, build-frontend ]
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
test_passed: ${{ steps.build_and_test.outputs.test_passed }}
|
||||
services:
|
||||
mongo:
|
||||
image: mongo:4.2
|
||||
@@ -179,19 +182,76 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.8'
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Test demo
|
||||
run: |
|
||||
pip install crawlab-demo
|
||||
crawlab-demo validate
|
||||
|
||||
- name: Log into registry
|
||||
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||
|
||||
- name: Push image
|
||||
- name: Build and test image
|
||||
id: build_and_test
|
||||
run: |
|
||||
# Update Dockerfile
|
||||
IMAGE_VERSION=${{needs.setup.outputs.version}}
|
||||
IMAGE_ID=$IMAGE_NAME_CRAWLAB
|
||||
docker tag image $IMAGE_ID:$IMAGE_VERSION
|
||||
docker push $IMAGE_ID:$IMAGE_VERSION
|
||||
if [[ $IMAGE_VERSION != "latest" ]]; then
|
||||
for n in crawlab-backend crawlab-frontend; do
|
||||
IMAGE_NAME=$n
|
||||
sed -i "s/${IMAGE_NAME}:latest/${IMAGE_NAME}:${IMAGE_VERSION}/" Dockerfile
|
||||
done
|
||||
fi
|
||||
|
||||
# Build image
|
||||
docker build . --file Dockerfile --tag image
|
||||
|
||||
# Test image
|
||||
docker run --rm -d --name crawlab_master \
|
||||
-e CRAWLAB_NODE_MASTER=true \
|
||||
-e CRAWLAB_DEMO=true \
|
||||
-e CRAWLAB_MONGO_HOST=localhost \
|
||||
-e CRAWLAB_MONGO_PORT=27017 \
|
||||
-p 8080:8080 \
|
||||
--network host \
|
||||
image
|
||||
docker exec crawlab_master env
|
||||
docker logs -f crawlab_master &
|
||||
sleep 10
|
||||
docker ps
|
||||
cmd='curl http://localhost:8080/api/system-info -s'
|
||||
echo "cmd: ${cmd}"
|
||||
res=`${cmd}`
|
||||
echo "res: ${res}"
|
||||
if [[ $res =~ "success" ]]; then
|
||||
echo "test_passed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "test_passed=false" >> $GITHUB_OUTPUT
|
||||
exit 1
|
||||
fi
|
||||
docker stop crawlab_master
|
||||
|
||||
push-images:
|
||||
needs: [setup, build-crawlab]
|
||||
if: needs.build-crawlab.outputs.test_passed == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
registry: [dockerhub, tencent]
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ (matrix.registry == 'dockerhub' && secrets.DOCKER_USERNAME) || (matrix.registry == 'tencent' && secrets.DOCKER_TENCENT_USERNAME) }}
|
||||
password: ${{ (matrix.registry == 'dockerhub' && secrets.DOCKER_PASSWORD) || (matrix.registry == 'tencent' && secrets.DOCKER_TENCENT_PASSWORD) }}
|
||||
|
||||
- name: Push to DockerHub
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ (matrix.registry == 'dockerhub' && env.IMAGE_NAME_CRAWLAB) || (matrix.registry == 'tencent' && env.IMAGE_NAME_CRAWLAB_TENCENT) }}:${{ needs.setup.outputs.version }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user