diff --git a/.github/workflows/containers.yaml b/.github/workflows/containers.yaml index 45d8a51..7b380f9 100644 --- a/.github/workflows/containers.yaml +++ b/.github/workflows/containers.yaml @@ -42,12 +42,12 @@ jobs: run: | echo "${{ steps.changed-files.outputs.other_modified_files }}" | python -c "import sys,json;d=json.dumps({'directories': sys.stdin.read().strip().split(' ')});print(f'directories={d}')" >> $GITHUB_OUTPUT - build-base-container: + build-minimal-notebook: if: needs.detect-changes.outputs.modified_files_count > 0 needs: - detect-changes runs-on: ubuntu-latest - name: Build base container + name: Build minimal-notebook permissions: packages: write steps: @@ -67,35 +67,60 @@ jobs: pushd dockerfiles/minimal-notebook echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT - uses: docker/build-push-action@v4 - if: github.event_name == 'pull_request' with: cache-from: type=gha cache-to: type=gha,mode=max context: dockerfiles/minimal-notebook - pull: true - push: true - tags: ghcr.io/esgf-nimbus/minimal-notebook:cache + push: ${{ github.event_name == 'push' }} + tags: ghcr.io/esgf-nimbus/minimal-notebook:${{ steps.get-version.outputs.version }} + + build-climate-notebook: + if: needs.detect-changes.outputs.modified_files_count > 0 + needs: + - detect-changes + - build-minimal-notebook + runs-on: ubuntu-latest + name: Build climate-notebook + permissions: + packages: write + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v2 + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + - id: get-version + run: | + pip install tbump + pushd dockerfiles/climate-notebook + echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT - uses: docker/build-push-action@v4 - if: github.event_name == 'push' with: cache-from: type=gha cache-to: type=gha,mode=max context: dockerfiles/minimal-notebook - pull: true - push: true - tags: ghcr.io/esgf-nimbus/minimal-notebook:${{ steps.get-version.outputs.version }} + push: ${{ github.event_name == 'push' }} + tags: ghcr.io/esgf-nimbus/climate-notebook:${{ steps.get-version.outputs.version }} build-other-containers: if: always() && needs.detect-changes.outputs.other_modified_files_count > 0 needs: - detect-changes - - build-base-container + - build-climate-notebook runs-on: ubuntu-latest name: Build other containers permissions: packages: write strategy: matrix: ${{ fromJSON(needs.detect-changes.outputs.directories) }} + exclude: + - directories: minimal-notebook + - directories: climate-notebook steps: - uses: actions/checkout@v3 - uses: docker/setup-buildx-action@v2 @@ -113,21 +138,9 @@ jobs: pushd dockerfiles/${{ matrix.directories }} echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT - uses: docker/build-push-action@v4 - if: github.event_name == 'pull_request' - with: - cache-from: type=gha - cache-to: type=gha,mode=max - context: dockerfiles/${{ matrix.directories }} - build-args: ${{ (contains(matrix.directories, 'minimal-notebook') || contains(matrix.directories, 'nimbus')) && 'TAG=cache' || '' }} - pull: true - push: true - tags: ghcr.io/esgf-nimbus/${{ matrix.directories }}:cache - - uses: docker/build-push-action@v4 - if: github.event_name == 'push' with: cache-from: type=gha cache-to: type=gha,mode=max context: dockerfiles/${{ matrix.directories }} - pull: true - push: true + push: ${{ github.event_name == 'push' }} tags: ghcr.io/esgf-nimbus/${{ matrix.directories }}:${{ steps.get-version.outputs.version }}