|
| 1 | +name: Build Tutorial Docker Image |
| 2 | + |
| 3 | +# This workflow runs on the PUBLIC repo (CIMFlow.git), not the private one. |
| 4 | +# It builds Docker images that are fully self-contained - the Dockerfile |
| 5 | +# clones from public repos only, no private access needed. |
| 6 | + |
| 7 | +on: |
| 8 | + # Manual trigger only - tutorial image is built locally and pushed manually |
| 9 | + # This avoids wasting CI minutes on long LLVM builds (~45 min) |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + push_image: |
| 13 | + description: 'Push image to registry' |
| 14 | + required: true |
| 15 | + default: 'true' |
| 16 | + type: choice |
| 17 | + options: |
| 18 | + - 'true' |
| 19 | + - 'false' |
| 20 | + |
| 21 | +env: |
| 22 | + REGISTRY: ghcr.io |
| 23 | + IMAGE_NAME: buaa-ci-lab/cimflow-tutorial |
| 24 | + |
| 25 | +# Prevent concurrent builds of the same branch/tag |
| 26 | +concurrency: |
| 27 | + group: docker-${{ github.ref }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +jobs: |
| 31 | + build-and-push: |
| 32 | + name: Build Tutorial Image |
| 33 | + runs-on: ubuntu-latest |
| 34 | + timeout-minutes: 90 # LLVM build can take 30+ minutes |
| 35 | + |
| 36 | + # Manual dispatch only - build locally for testing, use CI for convenience if needed |
| 37 | + |
| 38 | + permissions: |
| 39 | + contents: read |
| 40 | + packages: write |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@v4 |
| 45 | + # Note: No submodules needed - Dockerfile.tutorial clones from GitHub directly |
| 46 | + |
| 47 | + - name: Verify public repo configuration |
| 48 | + # Skip in private repo (manual dispatch for testing) |
| 49 | + if: github.repository == 'BUAA-CI-LAB/CIMFlow' |
| 50 | + run: | |
| 51 | + echo "Checking .gitmodules for private repo references..." |
| 52 | + if grep -q "Private" .gitmodules 2>/dev/null; then |
| 53 | + echo "::error::ERROR: .gitmodules contains 'Private' references!" |
| 54 | + echo "This workflow should only run on the release branch with public submodules." |
| 55 | + echo "" |
| 56 | + echo "Current .gitmodules:" |
| 57 | + cat .gitmodules |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | + echo "OK: Using public submodules" |
| 61 | + cat .gitmodules |
| 62 | +
|
| 63 | + - name: Set up Docker Buildx |
| 64 | + uses: docker/setup-buildx-action@v3 |
| 65 | + |
| 66 | + - name: Log in to Container Registry |
| 67 | + if: github.event_name != 'pull_request' |
| 68 | + uses: docker/login-action@v3 |
| 69 | + with: |
| 70 | + registry: ${{ env.REGISTRY }} |
| 71 | + username: ${{ github.actor }} |
| 72 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Extract metadata |
| 75 | + id: meta |
| 76 | + uses: docker/metadata-action@v5 |
| 77 | + with: |
| 78 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 79 | + tags: | |
| 80 | + type=ref,event=branch |
| 81 | + type=ref,event=tag |
| 82 | + type=raw,value=latest,enable={{is_default_branch}} |
| 83 | + type=sha,prefix= |
| 84 | +
|
| 85 | + - name: Build and push tutorial image |
| 86 | + id: build |
| 87 | + uses: docker/build-push-action@v5 |
| 88 | + with: |
| 89 | + context: . |
| 90 | + file: ./docker/Dockerfile.tutorial |
| 91 | + push: ${{ github.event_name != 'pull_request' && (github.event.inputs.push_image != 'false') }} |
| 92 | + tags: ${{ steps.meta.outputs.tags }} |
| 93 | + labels: ${{ steps.meta.outputs.labels }} |
| 94 | + cache-from: type=gha |
| 95 | + cache-to: type=gha,mode=max |
| 96 | + platforms: linux/amd64 |
| 97 | + |
| 98 | + - name: Image digest |
| 99 | + run: echo ${{ steps.build.outputs.digest }} |
| 100 | + |
| 101 | + build-dev-base: |
| 102 | + name: Build Dev Base Image |
| 103 | + runs-on: ubuntu-latest |
| 104 | + timeout-minutes: 30 # Base image is much faster (no LLVM build) |
| 105 | + |
| 106 | + # Manual dispatch only - build locally for testing, use CI for convenience if needed |
| 107 | + |
| 108 | + permissions: |
| 109 | + contents: read |
| 110 | + packages: write |
| 111 | + |
| 112 | + steps: |
| 113 | + - name: Checkout repository |
| 114 | + uses: actions/checkout@v4 |
| 115 | + |
| 116 | + - name: Set up Docker Buildx |
| 117 | + uses: docker/setup-buildx-action@v3 |
| 118 | + |
| 119 | + - name: Log in to Container Registry |
| 120 | + if: github.event_name != 'pull_request' |
| 121 | + uses: docker/login-action@v3 |
| 122 | + with: |
| 123 | + registry: ${{ env.REGISTRY }} |
| 124 | + username: ${{ github.actor }} |
| 125 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 126 | + |
| 127 | + - name: Build and push dev-base image |
| 128 | + uses: docker/build-push-action@v5 |
| 129 | + with: |
| 130 | + context: . |
| 131 | + file: ./docker/Dockerfile.dev-base |
| 132 | + push: ${{ github.event_name != 'pull_request' && (github.event.inputs.push_image != 'false') }} |
| 133 | + tags: | |
| 134 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev-base |
| 135 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev-base-${{ github.sha }} |
| 136 | + cache-from: type=gha |
| 137 | + cache-to: type=gha,mode=max |
| 138 | + platforms: linux/amd64 |
0 commit comments