Skip to content

Merge pull request #41 from shaneknapp/more-fixes #31

Merge pull request #41 from shaneknapp/more-fixes

Merge pull request #41 from shaneknapp/more-fixes #31

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
IMAGE: ${{ vars.IMAGE }}
outputs:
image-tag: ${{ steps.build-and-push.outputs.IMAGE_SHA_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: ${{ env.IMAGE }}
#IMAGE_NAME: ucb-datahub-2018/user-images/logodev-user-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
# Lets us monitor disks getting full as images get bigger over time
- name: Show how much disk space is left
run: df -h
create-pr:
runs-on: ubuntu-latest
needs: build-and-push
env:
HUB: ${{ vars.HUB }}
IMAGE: ${{ vars.IMAGE }}
steps:
- name: print the hash
run: |
echo $IMAGE_TAG
echo ${{ needs.build-and-push.outputs.image-tag }}
echo "IMAGE_TAG=${{ needs.build-and-push.outputs.image-tag }}" >> $GITHUB_ENV
- name: logic test to see if we should create a PR
id: set-create-pr
run: |
if [ -z "$IMAGE_TAG" ]; then
echo "CREATE_PR=false" >> $GITHUB_ENV
echo "::set-output name=create_pr::false"
else
echo "CREATE_PR=true" >> $GITHUB_ENV
echo "::set-output name=create_pr::true"
fi
- name: Checkout files in repo
if: ${{ steps.set-create-pr.outputs.create_pr }} == 'true'
uses: actions/checkout@v4
with:
repository: 'berkeley-dsep-infra/datahub'
sparse-checkout: |
hub/
deployments/${{ env.HUB }}
- name: see if the correct dir has been checked out, and the requirements have been installed
run: |
ls -la
tree