Jupyter: Create the log directory on container start instead of in th… #20
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Brev Tutorial Docker Images | |
| on: | |
| push: | |
| branches: | |
| - brev-reorg | |
| jobs: | |
| discover-tutorials: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tutorials: ${{ steps.find-tutorials.outputs.tutorials }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Find tutorial directories | |
| id: find-tutorials | |
| run: | | |
| tutorials=$(find tutorials -mindepth 1 -maxdepth 1 -type d | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| echo "tutorials=${tutorials}" >> $GITHUB_OUTPUT | |
| echo "Found tutorials: ${tutorials}" | |
| build-and-push: | |
| needs: discover-tutorials | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| tutorial: ${{ fromJson(needs.discover-tutorials.outputs.tutorials) }} | |
| fail-fast: false | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get branch name | |
| run: echo "GIT_BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
| - name: Set image name | |
| id: set-image | |
| run: | | |
| image_name="ghcr.io/${{ github.repository_owner }}/$(basename ${{ matrix.tutorial }})-tutorial" | |
| echo "image_name=${image_name,,}" >> $GITHUB_OUTPUT | |
| - name: Check for HPCCM recipe | |
| id: check-hpccm | |
| run: | | |
| if [ -f "${{ matrix.tutorial }}/brev/docker-recipe.py" ]; then | |
| echo "has_hpccm=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_hpccm=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set up Python (for HPCCM) | |
| if: steps.check-hpccm.outputs.has_hpccm == 'true' | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Install HPCCM | |
| if: steps.check-hpccm.outputs.has_hpccm == 'true' | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install hpccm | |
| - name: Generate Dockerfile from HPCCM recipe | |
| if: steps.check-hpccm.outputs.has_hpccm == 'true' | |
| run: | | |
| hpccm --recipe ${{ matrix.tutorial }}/brev/docker-recipe.py --format docker > ${{ matrix.tutorial }}/brev/dockerfile | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Docker image with Compose | |
| run: docker compose -f ${{ matrix.tutorial }}/brev/docker-compose.yml build | |
| - name: Tag Docker images | |
| run: | | |
| docker tag "${{ steps.set-image.outputs.image_name }}:${GIT_BRANCH_NAME}-latest" "${{ steps.set-image.outputs.image_name }}:${GIT_BRANCH_NAME}-latest" | |
| docker tag "${{ steps.set-image.outputs.image_name }}:${GIT_BRANCH_NAME}-latest" "${{ steps.set-image.outputs.image_name }}:${GIT_BRANCH_NAME}-git-${GITHUB_SHA::7}" | |
| - name: Push Docker images | |
| run: | | |
| docker push "${{ steps.set-image.outputs.image_name }}:${GIT_BRANCH_NAME}-latest" | |
| docker push "${{ steps.set-image.outputs.image_name }}:${GIT_BRANCH_NAME}-git-${GITHUB_SHA::7}" |