Merge pull request #29 from shaneknapp/test-mostly-complete-workflow #19
This file contains 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 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 }} | |
outputs: | |
image-tag: ${{ steps.build-and-push.outputs.image-tag }} | |
steps: | |
- name: Generate the image name | |
run: | | |
IMAGE="ucb-datahub-2018/user-images/${HUB}-user-image" | |
echo "IMAGE=$IMAGE" >> $GITHUB_ENV | |
- name: Echo the image and hub names | |
run: | | |
echo "$IMAGE" | |
echo "$HUB" | |
- name: Maximize build space | |
if: steps.changed-files.outputs.any_changed == 'true' | |
uses: easimon/maximize-build-space@v10 | |
with: | |
root-reserve-mb: 1024 | |
swap-size-mb: 1024 | |
remove-dotnet: 'true' | |
- 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 }} | |
# Lets us monitor disks getting full as images get bigger over time | |
- name: Show how much disk space is left | |
run: df -h |