99
1010permissions :
1111 contents : read
12- packages : read
1312
1413concurrency :
1514 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -18,18 +17,23 @@ concurrency:
1817jobs :
1918 unit-tests :
2019 runs-on : ubuntu-latest
20+ env :
21+ HAS_GHCR_PAT : ${{ secrets.GHCR_PAT != '' }}
2122 steps :
2223 - name : Checkout
2324 uses : actions/checkout@v6
2425 - name : Set up Docker Buildx
2526 uses : docker/setup-buildx-action@v3
2627
2728 - name : Login to GHCR
29+ if : ${{ env.HAS_GHCR_PAT == 'true' }}
2830 uses : docker/login-action@v3
31+ env :
32+ GHCR_PAT : ${{ secrets.GHCR_PAT }}
2933 with :
3034 registry : ghcr.io
3135 username : ${{ github.actor }}
32- password : ${{ secrets .GHCR_PAT || github.token }}
36+ password : ${{ env .GHCR_PAT }}
3337
3438 - name : Free up disk space on Ubuntu
3539 run : |
@@ -55,17 +59,32 @@ jobs:
5559 # Calculate image tags that match what Python code expects
5660 # Python generates: locally-built-{sanitized_path}:{sha256_hash[:12]}
5761 REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
58- CACHE_ARGS_NEMO=(--cache-from type=registry,ref=ghcr.io/${REPO_LOWER}/nemo-skills-image:cache )
59- CACHE_ARGS_SANDBOX=(--cache-from type=registry,ref=ghcr.io/${REPO_LOWER}/nemo-skills-sandbox-image:cache )
62+ CACHE_ARGS_NEMO=()
63+ CACHE_ARGS_SANDBOX=()
6064 if [ -n "${GHCR_PAT:-}" ]; then
65+ CACHE_ARGS_NEMO+=(--cache-from type=registry,ref=ghcr.io/${REPO_LOWER}/nemo-skills-image:cache)
6166 CACHE_ARGS_NEMO+=(--cache-to type=registry,ref=ghcr.io/${REPO_LOWER}/nemo-skills-image:cache,mode=min)
67+ CACHE_ARGS_SANDBOX+=(--cache-from type=registry,ref=ghcr.io/${REPO_LOWER}/nemo-skills-sandbox-image:cache)
6268 CACHE_ARGS_SANDBOX+=(--cache-to type=registry,ref=ghcr.io/${REPO_LOWER}/nemo-skills-sandbox-image:cache,mode=min)
6369 fi
6470
71+ retry_docker_build() {
72+ for attempt in 1 2 3; do
73+ if docker buildx build "$@"; then
74+ return 0
75+ fi
76+ if [ "$attempt" -lt 3 ]; then
77+ echo "Docker build failed on attempt ${attempt}; retrying in 30s..."
78+ sleep 30
79+ fi
80+ done
81+ return 1
82+ }
83+
6584 # Build nemo-skills-image with expected tag
6685 NEMO_SKILLS_HASH=$(sha256sum dockerfiles/Dockerfile.nemo-skills | cut -d' ' -f1 | cut -c1-12)
6786 NEMO_SKILLS_TAG="locally-built-dockerfiles-dockerfile-nemo-skills:${NEMO_SKILLS_HASH}"
68- docker buildx build \
87+ retry_docker_build \
6988 --tag nemo-skills-image \
7089 --tag ${NEMO_SKILLS_TAG} \
7190 --file dockerfiles/Dockerfile.nemo-skills \
82101 # Build sandbox-image with expected tag
83102 SANDBOX_HASH=$(sha256sum dockerfiles/Dockerfile.sandbox | cut -d' ' -f1 | cut -c1-12)
84103 SANDBOX_TAG="locally-built-dockerfiles-dockerfile-sandbox:${SANDBOX_HASH}"
85- docker buildx build \
104+ retry_docker_build \
86105 --tag nemo-skills-sandbox-image \
87106 --tag ${SANDBOX_TAG} \
88107 --file dockerfiles/Dockerfile.sandbox \
0 commit comments