-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 2.39 KB
/
Copy pathdocker.yml
File metadata and controls
67 lines (59 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: docker
on:
push:
branches:
- main
paths:
- 'Dockerfile.jhub'
- 'jhub-env.lock'
- '.github/workflows/docker.yml'
pull_request:
permissions:
contents: read
actions: write # for type=gha cache writes
env:
IMAGE_NAME: diffuseproject/mdx2-jhub
IMAGE_TAG: 1.0.2-1
# HEAD of feat/jupyterhub-singleuser (PR #56 source ref) on 2026-02-25 —
# the commit diffuseproject/mdx2:test was originally built from
# (mdx2/VERSION=1.0.2). Reachable only via refs/pull/56/head since the
# branch was deleted post-merge; the Dockerfile fetches that ref
# explicitly. Bump together with IMAGE_TAG when shipping an mdx2 source
# upgrade (e.g. v1.0.4 -> 07f074a, IMAGE_TAG 1.0.2-1 -> 1.0.4-1).
MDX2_COMMIT: 327bf6e1541e3e0b63a22c8aff100b92c4aa6e39
jobs:
jhub:
name: jhub image (singleuser)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Refuse to overwrite an already-published tag
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
if docker manifest inspect "${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" >/dev/null 2>&1; then
echo "::error::Tag ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} already exists on Dockerhub."
echo "::error::Image tags are immutable. Bump IMAGE_TAG in .github/workflows/docker.yml"
echo "::error::(e.g. 1.0.2-1 -> 1.0.2-2 for stack/lockfile changes; 1.0.3-1 for mdx2 source bump) and merge again."
exit 1
fi
echo "Tag ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} is free to publish."
- name: Build (and push on main)
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.jhub
build-args: |
MDX2_COMMIT=${{ env.MDX2_COMMIT }}
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
cache-from: type=gha,scope=jhub
cache-to: type=gha,mode=max,scope=jhub