Skip to content

Merge pull request #36 from berkeley-dsep-infra/shaneknapp-patch-1 #26

Merge pull request #36 from berkeley-dsep-infra/shaneknapp-patch-1

Merge pull request #36 from berkeley-dsep-infra/shaneknapp-patch-1 #26

name: Build and push container image
# try to follow the example here: https://gist.github.com/Daniel-ltw/552b90800b07c22e4a83dfa68ada6318
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
DOCKER_CONFIG: $HOME/.docker
HUB: ${{ vars.HUB }}
IMAGE: ${{ vars.IMAGE }}
outputs:
image-tag: ${{ steps.build-and-push.outputs.image-tag }}
steps:
- name: cleanup disk space
run: |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
df -h
- name: Display the image and hub names
run: |
echo "$IMAGE"
echo "$HUB"
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files_ignore: |
.github/**
images/**
- name: Log in to GAR
if: steps.changed-files.outputs.any_changed == 'true'
uses: docker/login-action@v1
with:
registry: us-central1-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_SECRET_KEY }}
- name: Build the image and push to artifact registry
id: build-and-push
if: steps.changed-files.outputs.any_changed == 'true'
uses: jupyterhub/repo2docker-action@master
with:
# Make sure username & password/token pair matches your registry credentials
DOCKER_REGISTRY: us-central1-docker.pkg.dev
IMAGE_NAME: $IMAGE
# Disable pushing a 'latest' tag, as this often just causes confusion
LATEST_TAG_OFF: true
# Put repo contents in /srv/repo, rather than the default (/home/jovyan). The home directory
# is mounted over by persistent storage when we are using the built image in a JupyterHub, and
# so all contents put in /home/jovyan are lost. This particularly prevents any 'start' script from
# working, as it is needed in runtime.
REPO_DIR: /srv/repo
- name: print the image name
run: |
echo ${{ steps.build-and-push.outputs.IMAGE_SHA_TAG }}
- name: Save image tag as an artifact
run: echo ${{ steps.build-and-push.outputs.IMAGE_SHA_TAG }} > image-tag.txt
- uses: actions/upload-artifact@v4
with:
name: image-tag
path: ./image-tag.txt
compression-level: 0
# Lets us monitor disks getting full as images get bigger over time
- name: Show how much disk space is left
run: df -h