|
1 | | -name: Image Build and Push |
| 1 | +name: Build and Push Binder Image |
| 2 | + |
| 3 | +# Builds the Underworld3 binder-ready Docker image and pushes to GHCR |
| 4 | +# The image is used by mybinder.org via the uw3-binder-launcher repository |
2 | 5 |
|
3 | 6 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - development |
| 7 | + push: |
| 8 | + branches: [main, uw3-release-candidate, development] |
| 9 | + paths: |
| 10 | + # Only rebuild when these files change (Cython/dependencies require rebuild) |
| 11 | + - 'container/Dockerfile.base.optimized' |
| 12 | + - 'pixi.toml' |
| 13 | + - 'pixi.lock' |
| 14 | + - 'src/**/*.pyx' |
| 15 | + - 'src/**/*.c' |
| 16 | + - 'setup.py' |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + force_rebuild: |
| 20 | + description: 'Force full rebuild (no cache)' |
| 21 | + type: boolean |
| 22 | + default: false |
7 | 23 |
|
8 | 24 | jobs: |
9 | | - push-to-dockerhub: |
| 25 | + build-and-push: |
10 | 26 | runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + packages: write |
11 | 30 |
|
12 | 31 | steps: |
13 | 32 | - name: Checkout repository |
14 | 33 | uses: actions/checkout@v4 |
15 | 34 |
|
16 | | - - name: Exact branch name |
17 | | - run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV |
| 35 | + - name: Set up Docker Buildx |
| 36 | + uses: docker/setup-buildx-action@v3 |
18 | 37 |
|
19 | | - - name: Login to DockerHub |
| 38 | + - name: Login to GHCR |
20 | 39 | uses: docker/login-action@v3 |
21 | 40 | with: |
22 | | - username: ${{ secrets.XXX_USERNAME }} |
23 | | - password: ${{ secrets.XXX_PWORD }} |
| 41 | + registry: ghcr.io |
| 42 | + username: ${{ github.actor }} |
| 43 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + - name: Extract branch name |
| 46 | + run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV |
24 | 47 |
|
25 | 48 | - name: Build and push Docker image |
26 | | - uses: docker/build-push-action@v6 |
| 49 | + uses: docker/build-push-action@v5 |
27 | 50 | with: |
28 | 51 | context: . |
| 52 | + file: container/Dockerfile.base.optimized |
29 | 53 | push: true |
30 | | - file: ./Dockerfile |
31 | 54 | platforms: linux/amd64 |
32 | | - # see https://github.com/docker/build-push-action/issues/276 for syntax help |
33 | | - tags: underworldcode/underworld3:${{ env.BRANCH }} #-$(date +%s) |
| 55 | + no-cache: ${{ inputs.force_rebuild || false }} |
| 56 | + tags: | |
| 57 | + ghcr.io/underworldcode/uw3-base:${{ env.BRANCH }}-slim |
| 58 | + ghcr.io/underworldcode/uw3-base:latest-slim |
| 59 | +
|
| 60 | + # Trigger launcher repo to update its Dockerfile reference |
| 61 | + # Requires LAUNCHER_PAT secret (Personal Access Token with repo scope) |
| 62 | + - name: Trigger launcher update |
| 63 | + if: success() |
| 64 | + uses: peter-evans/repository-dispatch@v2 |
| 65 | + with: |
| 66 | + token: ${{ secrets.LAUNCHER_PAT }} |
| 67 | + repository: underworldcode/uw3-binder-launcher |
| 68 | + event-type: image-updated |
| 69 | + client-payload: '{"branch": "${{ env.BRANCH }}"}' |
0 commit comments