♻️ Change to reuse the document operation reusable workflow at the do… #112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: docker-ci | ||
| on: | ||
| push: | ||
| branches: | ||
| - "<your_base_branch>" | ||
| paths: | ||
| # For GitHub Action | ||
| - ".github/workflows/docker-ci.yml" | ||
| # For source code and test | ||
| - "<your_package_name>/**/*.py" | ||
| - "!**/__pkg_info__.py" | ||
| # For docker configuration and shell script for running by Docker | ||
| - "Dockerfile" | ||
| - "scripts/docker/run-server.sh" | ||
| # For Python project configuration | ||
| - "pyproject.toml" | ||
| - "uv.lock" | ||
| # For the push event, in addition to build and test would be run, it would trigger other service to keep the reports | ||
| # or other checking, i.e., record the test report by CodeCov and check the code quality by SonarQube. | ||
| pull_request: | ||
| branches: | ||
| - "<your_base_branch>" | ||
| paths: | ||
| # For GitHub Action | ||
| - ".github/workflows/docker-ci.yml" | ||
| # For source code and test | ||
| - "<your_package_name>/**/*.py" | ||
| - "!**/__pkg_info__.py" | ||
| # For docker configuration and shell script for running by Docker | ||
| - "Dockerfile" | ||
| - "scripts/docker/run-server.sh" | ||
| # For Python project configuration | ||
| - "pyproject.toml" | ||
| - "uv.lock" | ||
| env: | ||
| TEST_TAG: user/<your_project_name>:test | ||
| TEST_CONTAINER_NAME: <your_project_name> | ||
| jobs: | ||
| image-check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| with: | ||
| buildkitd-flags: --debug | ||
| - name: Validate build configuration | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| call: check | ||
| tags: user/app:latest | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| image-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| with: | ||
| buildkitd-flags: --debug | ||
| - name: Build and export to Docker | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| load: true | ||
| tags: ${{ env.TEST_TAG }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| - name: Test | ||
| run: | | ||
| docker run -e API_TOKEN=${{ secrets.<YOUR_API_TOKEN_SECRET> }} -d --rm --name ${{ env.TEST_CONTAINER_NAME }} ${{ env.TEST_TAG }} | ||
| echo "Waiting for the server to start..." | ||
| sleep 5 | ||
| docker logs ${{ env.TEST_CONTAINER_NAME }} | ||