diff --git a/.github/workflows/docker-crawlab.yml b/.github/workflows/docker-crawlab.yml index 0ff5d04e..d7e7573b 100644 --- a/.github/workflows/docker-crawlab.yml +++ b/.github/workflows/docker-crawlab.yml @@ -28,7 +28,8 @@ jobs: dockerfile_changed: ${{ steps.check_changed_files.outputs.dockerfile_changed }} version: ${{ steps.version.outputs.version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Get changed files id: changed_files uses: tj-actions/changed-files@v45 @@ -46,6 +47,7 @@ jobs: - '${{ env.IMAGE_PATH_CRAWLAB_FRONTEND }}/**' dockerfile: - 'Dockerfile' + - id: check_changed_files name: Check changed files run: | @@ -89,11 +91,13 @@ jobs: ports: - 27017:27017 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: go-version: '1.22' + - name: Run tests run: | cd core @@ -112,7 +116,7 @@ jobs: if: needs.setup.outputs.backend_changed == 'true' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build image run: | cd $IMAGE_PATH_CRAWLAB_BACKEND @@ -131,7 +135,7 @@ jobs: if: needs.setup.outputs.frontend_changed == 'true' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build image run: | cd $IMAGE_PATH_CRAWLAB_FRONTEND @@ -159,7 +163,8 @@ jobs: ports: - 27017:27017 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Update Dockerfile run: | IMAGE_VERSION=${{needs.setup.outputs.version}} @@ -175,50 +180,6 @@ jobs: - name: Test image run: | - 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 - : - else - exit 1 - fi - docker stop crawlab_master - - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.12' - - - name: Build and test image - id: build_and_test - run: | - # Update Dockerfile - IMAGE_VERSION=${{needs.setup.outputs.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 \ @@ -237,13 +198,14 @@ jobs: echo "res: ${res}" docker stop crawlab_master if [[ $res =~ "success" ]]; then - : + echo "Test passed successfully" else + echo "Test failed" exit 1 fi push_images: - if: ${{ needs.build_crawlab.result == 'success' }} + if: ${{ always() && needs.build_crawlab.result == 'success' }} needs: [setup, build_crawlab] runs-on: ubuntu-latest strategy: @@ -254,16 +216,17 @@ jobs: uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: + registry: ${{ (matrix.registry == 'dockerhub' && '') || (matrix.registry == 'tencent' && 'ccr.ccs.tencentyun.com') }} 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 + uses: docker/build-push-action@v6 with: push: true tags: ${{ (matrix.registry == 'dockerhub' && env.IMAGE_NAME_CRAWLAB) || (matrix.registry == 'tencent' && env.IMAGE_NAME_CRAWLAB_TENCENT) }}:${{ needs.setup.outputs.version }} diff --git a/backend/README.md b/backend/README.md index a1d4b01a..dafe39e1 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,3 +1,4 @@ # crawlab-backend Backend (Golang) for Crawlab +