Skip to content

Commit

Permalink
Do not hardcode owner of the image (#1769)
Browse files Browse the repository at this point in the history
* Do not hardcode owner of the image

* Fix
  • Loading branch information
mathbunnyru committed Aug 11, 2022
1 parent b159a79 commit 64c4cd7
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/docker-build-test-upload.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Download parent image, build new one, test it and upload to GitHub artifacts

env:
OWNER: ${{ github.repository_owner }}

on:
workflow_call:
inputs:
Expand Down Expand Up @@ -45,19 +48,19 @@ jobs:
platform: ${{ inputs.platform }}

- name: Build image 🛠
run: docker build --rm --force-rm --tag jupyter/${{ inputs.image }} ${{ inputs.image }}/
run: docker build --rm --force-rm --tag ${{ env.OWNER }}/${{ inputs.image }} ${{ inputs.image }}/
env:
DOCKER_BUILDKIT: 1
# Full logs for CI build
BUILDKIT_PROGRESS: plain
shell: bash

- name: Run tests ✅
run: python3 -m tests.run_tests --short-image-name ${{ inputs.image }}
run: python3 -m tests.run_tests --short-image-name ${{ inputs.image }} --owner ${{ env.OWNER }}
shell: bash

- name: Save image as a tar for later use 💾
run: docker save jupyter/${{ inputs.image }} -o /tmp/${{ inputs.image }}-${{ inputs.platform }}.tar
run: docker save ${{ env.OWNER }}/${{ inputs.image }} -o /tmp/${{ inputs.image }}-${{ inputs.platform }}.tar
shell: bash
- name: Upload image as artifact 💾
uses: actions/upload-artifact@v3
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/docker-tag-manifest-push.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Download Docker image from GitHub artifacts, tag and push it to DockerHub

env:
OWNER: ${{ github.repository_owner }}

on:
workflow_call:
inputs:
Expand Down Expand Up @@ -54,12 +57,12 @@ jobs:

- name: Create tags 🏷
run: |
python3 -m tagging.tag_image --short-image-name ${{ matrix.image }}
python3 -m tagging.tag_image --short-image-name ${{ matrix.image }} --owner ${{ env.OWNER }}
docker image ls -a
shell: bash

- name: Write manifest and build history file 🏷
run: python3 -m tagging.write_manifest --short-image-name ${{ matrix.image }} --hist-line-dir /tmp/hist_lines/ --manifest-dir /tmp/manifests/
run: python3 -m tagging.write_manifest --short-image-name ${{ matrix.image }} --hist-line-dir /tmp/hist_lines/ --manifest-dir /tmp/manifests/ --owner ${{ env.OWNER }}
shell: bash
- name: Upload manifest file 💾
uses: actions/upload-artifact@v3
Expand All @@ -76,7 +79,7 @@ jobs:

- name: Remove aarch64 latest tag 🗑️
if: ${{ inputs.platform != 'amd64' }}
run: docker rmi jupyter/${{ matrix.image }}
run: docker rmi ${{ env.OWNER }}/${{ matrix.image }}
shell: bash

- name: Login to Docker Hub 🔐
Expand All @@ -88,5 +91,5 @@ jobs:

- name: Push Images to Docker Hub 📤
if: github.ref == 'refs/heads/main' || github.event_name == 'schedule'
run: docker push --all-tags jupyter/${{ matrix.image }}
run: docker push --all-tags ${{ env.OWNER }}/${{ matrix.image }}
shell: bash
5 changes: 4 additions & 1 deletion .github/workflows/hub-overview.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Update dockerhub overviews

env:
OWNER: ${{ github.repository_owner }}

on:
push:
branches:
Expand Down Expand Up @@ -36,7 +39,7 @@ jobs:
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKERHUB_TOKEN }}
with:
destination_container_repo: jupyter/base-notebook
destination_container_repo: ${{ env.OWNER }}/base-notebook
provider: dockerhub
short_description: "Small base image for Jupyter Notebook stacks from https://github.com/jupyter/docker-stacks"
readme_file: base-notebook/README.md
6 changes: 5 additions & 1 deletion tagging/tag_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def tag_image(short_image_name: str, owner: str) -> None:
required=True,
help="Short image name to apply tags for",
)
arg_parser.add_argument("--owner", default="jupyter", help="Owner of the image")
arg_parser.add_argument(
"--owner",
required=True,
help="Owner of the image",
)
args = arg_parser.parse_args()

tag_image(args.short_image_name, args.owner)
6 changes: 5 additions & 1 deletion tagging/write_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ def write_manifest(
type=Path,
help="Directory to save manifest file",
)
arg_parser.add_argument("--owner", default="jupyter", help="Owner of the image")
arg_parser.add_argument(
"--owner",
required=True,
help="Owner of the image",
)
args = arg_parser.parse_args()

LOGGER.info(f"Current build timestamp: {BUILD_TIMESTAMP}")
Expand Down
6 changes: 5 additions & 1 deletion tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def test_image(short_image_name: str, owner: str) -> None:
required=True,
help="Short image name to run test on",
)
arg_parser.add_argument("--owner", default="jupyter", help="Owner of the image")
arg_parser.add_argument(
"--owner",
required=True,
help="Owner of the image",
)

args = arg_parser.parse_args()

Expand Down

0 comments on commit 64c4cd7

Please sign in to comment.