diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 79153a5..5f365ca 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,6 +4,9 @@ on: push: branches: - main + pull_request: + branches: + - main jobs: build-and-push: @@ -23,9 +26,11 @@ jobs: - name: Checkout files in repo uses: actions/checkout@main - - name: Build and push the image to quay.io + - name: Build the image and push to quay.io if not a pull request uses: jupyterhub/repo2docker-action@master with: + # Don't push the image during a PR build + NO_PUSH: "${{ github.event_name == 'pull_request' }}" # Make sure username & password/token pair matches your registry credentials DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 31fb0f8..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Test container image build - -on: - pull_request: - -jobs: - test-build: - runs-on: ubuntu-latest - steps: - - # For biggish images, github actions runs out of disk space. - # So we cleanup some unwanted things in the disk image, and reclaim that space for our docker use - # https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150 - # and https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L104 - # This gives us a total of about 52G of free space, which should be enough for now - - name: cleanup disk space - run: | - sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc - df -h - - - name: checkout files in repo - uses: actions/checkout@main - - - name: Build the image and push it if `NO_PUSH` disabled - uses: jupyterhub/repo2docker-action@master - with: - NO_PUSH: "true" - DOCKER_REGISTRY: "quay.io" - # 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 - - # Uncomment and modify the following line with your image name. - # IMAGE_NAME: "/" - - # Lets us monitor disks getting full as images get bigger over time - - name: Show how much disk space is left - run: df -h diff --git a/README.md b/README.md index b06a237..f34c333 100644 --- a/README.md +++ b/README.md @@ -34,22 +34,20 @@ The `repo2docker-action` will update the [base repo2docker](https://github.com/j **Note:** A complete list of possible configuration files that can be added to the repository and be used by repo2docker to build the Docker image, can be found in the [repo2docker docs](https://repo2docker.readthedocs.io/en/latest/config_files.html#configuration-files). -### The GitHub workflows +### The GitHub Action workflows -This template repository provides two GitHub workflows that can build and push the image to quay.io when configured. +This template repository provides some GitHub Action workflows that can build and push the image to quay.io when configured, and test the image on Binder. ![Workflows](images/workflows.png) #### 1. Build and push container image :arrow_right: [build.yaml](https://github.com/2i2c-org/hub-user-image-template/blob/main/.github/workflows/build.yaml) -This workflow is triggered by every pushed commit on the main branch of the repo (including when a PR is merged). -It **builds** the image and **pushes** it to the registry. +This workflow is triggered by every pushed commit on the main branch of the repo (including when a PR is merged), and every commit made to a Pull Request opened against the default branch (`main`).. +It **builds** the image and **pushes** it to the registry _on pushes to the default branch_. +During PR builds, the image is **only** built and **not** pushed, unless explicitly configured to do so. +Checkout [this section](https://docs.2i2c.org/en/latest/admin/howto/environment/hub-user-image-template-guide.html#enable-quay-io-image-push-during-pull-requests) on how to enable image pushes on Pull Requests. -#### 2. Test container image build :arrow_right: [test.yaml](https://github.com/2i2c-org/hub-user-image-template/blob/MAIN/.github/workflows/test.yaml) - -This workflow is triggerd by every Pull Request commit and it **builds** the image, but it **doesn't** push it to the registry, unless explicitly configured to do so. Checkout [this section](https://docs.2i2c.org/en/latest/admin/howto/environment/hub-user-image-template-guide.html#enable-quay-io-image-push-for-test-yaml) on how to enable image pushes on Pull Requests. - -#### 3. Test this PR on Binder Badge :arrow_right: [binder.yaml](https://github.com/2i2c-org/hub-user-image-template/blob/MAIN/.github/workflows/binder.yaml) +#### 2. Test this PR on Binder Badge :arrow_right: [binder.yaml](https://github.com/2i2c-org/hub-user-image-template/blob/MAIN/.github/workflows/binder.yaml) This workflow posts a comment inside a pull request, every time a pull request gets opened. The comment contains a "Test this PR on Binder" badge, which can be used to access the image defined by the PR in [mybinder.org](https://mybinder.org/). diff --git a/images/workflows.png b/images/workflows.png index 0c7dce5..f71b58d 100644 Binary files a/images/workflows.png and b/images/workflows.png differ