Skip to content

Commit

Permalink
Updates workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonb5 committed Feb 21, 2024
1 parent 7a64382 commit 57774e1
Showing 1 changed file with 37 additions and 24 deletions.
61 changes: 37 additions & 24 deletions .github/workflows/containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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 }}

0 comments on commit 57774e1

Please sign in to comment.