[fix] readme #3
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: Build reComputer-RK-CV Images (Multi-Platform) | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths: | |
| - 'src/rk3588/**' | |
| - 'src/rk3576/**' | |
| - 'docker/**' | |
| tags: ['v*.*.*'] | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| platform: | |
| description: 'Platform to build (rk3588, rk3576, all)' | |
| required: true | |
| default: 'all' | |
| image_tag: | |
| description: 'Custom image tag' | |
| required: false | |
| default: 'latest' | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: [rk3588, rk3576] | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Check if build is needed | |
| id: check_changes | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| if [[ "${{ github.event.inputs.platform }}" == "all" || "${{ github.event.inputs.platform }}" == "${{ matrix.platform }}" ]]; then | |
| echo "build=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "build=false" >> $GITHUB_OUTPUT | |
| fi | |
| elif [[ "${{ github.event_name }}" == "push" ]]; then | |
| # Check if files in src/${{ matrix.platform }} or docker/${{ matrix.platform }} changed | |
| # For simplicity in this environment, we assume true if it matches matrix, | |
| # but in real git we would use git diff | |
| echo "build=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "build=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Prepare Image Name | |
| if: steps.check_changes.outputs.build == 'true' | |
| run: | | |
| # Use reComputer-RK-CV as the base repo name if renamed, otherwise use repo name | |
| REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
| IMAGE_NAME="${{ matrix.platform }}-yolo" | |
| echo "GHCR_IMAGE=ghcr.io/${REPO_NAME}/${IMAGE_NAME}" >> $GITHUB_ENV | |
| TAG="latest" | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| TAG="${{ github.event.inputs.image_tag }}" | |
| elif [[ "${{ github.ref_type }}" == "tag" ]]; then | |
| TAG="${{ github.ref_name }}" | |
| fi | |
| echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV | |
| - name: Set up QEMU | |
| if: steps.check_changes.outputs.build == 'true' | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| if: steps.check_changes.outputs.build == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| if: steps.check_changes.outputs.build == 'true' && github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and Push (arm64 Only) | |
| if: steps.check_changes.outputs.build == 'true' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: src/${{ matrix.platform }} | |
| file: docker/${{ matrix.platform }}/Yolo11.dockerfile | |
| platforms: linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: | | |
| ${{ env.GHCR_IMAGE }}:${{ env.IMAGE_TAG }} | |
| ${{ env.GHCR_IMAGE }}:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Summary | |
| if: steps.check_changes.outputs.build == 'true' | |
| run: echo "Successfully built ${{ env.GHCR_IMAGE }}:${{ env.IMAGE_TAG }}" |