|
| 1 | +name: Build OpenSpiel Base Image |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # Manual trigger only |
| 5 | + inputs: |
| 6 | + force_rebuild: |
| 7 | + description: 'Force rebuild even if base image exists' |
| 8 | + required: false |
| 9 | + default: 'false' |
| 10 | + type: boolean |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + IMAGE_PREFIX: ${{ github.repository_owner }}/openenv |
| 15 | + |
| 16 | +jobs: |
| 17 | + # Job 1: Build base image first |
| 18 | + build-base: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up Docker Buildx |
| 29 | + uses: docker/setup-buildx-action@v3 |
| 30 | + |
| 31 | + - name: Log in to GHCR |
| 32 | + uses: docker/login-action@v3 |
| 33 | + with: |
| 34 | + registry: ${{ env.REGISTRY }} |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Extract metadata for base image |
| 39 | + id: meta |
| 40 | + uses: docker/metadata-action@v5 |
| 41 | + with: |
| 42 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-base |
| 43 | + tags: | |
| 44 | + type=raw,value=latest,enable={{is_default_branch}} |
| 45 | + type=sha |
| 46 | +
|
| 47 | + - name: Build and push base image |
| 48 | + uses: docker/build-push-action@v5 |
| 49 | + with: |
| 50 | + context: . |
| 51 | + file: src/core/containers/images/Dockerfile |
| 52 | + push: true |
| 53 | + platforms: linux/amd64,linux/arm64 |
| 54 | + tags: ${{ steps.meta.outputs.tags }} |
| 55 | + labels: ${{ steps.meta.outputs.labels }} |
| 56 | + cache-from: type=gha,scope=base |
| 57 | + cache-to: type=gha,mode=max,scope=base |
| 58 | + |
| 59 | + # Job 2: Build OpenSpiel base image (depends on base) |
| 60 | + build-openspiel-base: |
| 61 | + runs-on: 8-core-ubuntu |
| 62 | + needs: build-base # Wait for base image to be built |
| 63 | + permissions: |
| 64 | + contents: read |
| 65 | + packages: write |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Checkout code |
| 69 | + uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Set up Docker Buildx |
| 72 | + uses: docker/setup-buildx-action@v3 |
| 73 | + |
| 74 | + - name: Log in to GHCR |
| 75 | + uses: docker/login-action@v3 |
| 76 | + with: |
| 77 | + registry: ${{ env.REGISTRY }} |
| 78 | + username: ${{ github.actor }} |
| 79 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + |
| 81 | + - name: Extract metadata for OpenSpiel base image |
| 82 | + id: meta-openspiel-base |
| 83 | + uses: docker/metadata-action@v5 |
| 84 | + with: |
| 85 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-openspiel-base |
| 86 | + tags: | |
| 87 | + type=raw,value=latest,enable={{is_default_branch}} |
| 88 | + type=sha |
| 89 | +
|
| 90 | + - name: Build and push OpenSpiel base image |
| 91 | + uses: docker/build-push-action@v5 |
| 92 | + with: |
| 93 | + context: . |
| 94 | + file: src/envs/openspiel_env/server/Dockerfile.openspiel-base |
| 95 | + push: true |
| 96 | + platforms: linux/amd64,linux/arm64 |
| 97 | + tags: ${{ steps.meta-openspiel-base.outputs.tags }} |
| 98 | + labels: ${{ steps.meta-openspiel-base.outputs.labels }} |
| 99 | + cache-from: type=gha,scope=openspiel-base |
| 100 | + cache-to: type=gha,mode=max,scope=openspiel-base |
| 101 | + |
| 102 | + - name: Build summary |
| 103 | + run: | |
| 104 | + echo "✅ OpenSpiel base image built and pushed successfully!" |
| 105 | + echo "📦 Image: ${{ steps.meta-openspiel-base.outputs.tags }}" |
| 106 | + echo "🚀 Next regular build will use this new base image" |
0 commit comments