Skip to content

Commit c9e511d

Browse files
committed
cicd:experiment
1 parent fde1a8c commit c9e511d

2 files changed

Lines changed: 206 additions & 2 deletions

File tree

.github/workflows/docker-ci.yml

Lines changed: 205 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,155 @@ jobs:
10761076
10771077
echo "✅ Local image cleanup completed"
10781078
1079+
DEPLOY-job:
1080+
needs: [BUILD-job, PREPARE-job, PUSH-PUBLIC-job]
1081+
runs-on: setonix-podman02
1082+
if: needs.PREPARE-job.outputs.proceed_valid == 'true' && (needs.PREPARE-job.outputs.dockerhub_available == 'true' || needs.PREPARE-job.outputs.quayio_available == 'true')
1083+
env:
1084+
DOCKERFILE_NAME: ${{ needs.BUILD-job.outputs.dockerfile_name }}
1085+
VERSION: ${{ needs.PREPARE-job.outputs.version }}
1086+
steps:
1087+
- name: Display deployment environment
1088+
run: |
1089+
echo "Hostname: $(hostname)"
1090+
echo "Starting SHPC deployment for ${DOCKERFILE_NAME}:${VERSION}"
1091+
echo ""
1092+
echo "Available public registries:"
1093+
if [ "${{ needs.PREPARE-job.outputs.dockerhub_available }}" = "true" ]; then
1094+
echo "• Docker Hub: ${{ vars.DOCKERHUB_USERNAME }}/${DOCKERFILE_NAME}:${VERSION}"
1095+
fi
1096+
if [ "${{ needs.PREPARE-job.outputs.quayio_available }}" = "true" ]; then
1097+
echo "• Quay.io: quay.io/${{ vars.QUAYIO_USERNAME }}/${DOCKERFILE_NAME}:${VERSION}"
1098+
fi
1099+
1100+
- name: Load SHPC module and setup environment
1101+
id: shpc_setup
1102+
run: |
1103+
set -euo pipefail
1104+
echo "Loading SHPC module..."
1105+
if module load shpc/0.1.32; then
1106+
echo "✓ SHPC module loaded successfully"
1107+
shpc --version
1108+
else
1109+
echo "✗ Failed to load SHPC module"
1110+
exit 1
1111+
fi
1112+
1113+
# Set SHPC registry path
1114+
SHPC_REGISTRY="/software/setonix/2025.08/pawsey/software/shpc/pawsey_registry"
1115+
echo "SHPC_REGISTRY=$SHPC_REGISTRY" >> $GITHUB_ENV
1116+
echo "SHPC registry path: $SHPC_REGISTRY"
1117+
1118+
- name: Determine deployment target and get SHA256 digest
1119+
id: get_image_info
1120+
run: |
1121+
set -euo pipefail
1122+
1123+
# Prioritize Quay.io if available, otherwise use Docker Hub
1124+
if [ "${{ needs.PREPARE-job.outputs.quayio_available }}" = "true" ]; then
1125+
full_image="quay.io/${{ vars.QUAYIO_USERNAME }}/${DOCKERFILE_NAME}:${VERSION}"
1126+
registry_url="https://quay.io/v2"
1127+
api_path="${{ vars.QUAYIO_USERNAME }}/${DOCKERFILE_NAME}"
1128+
registry_type="quay.io"
1129+
elif [ "${{ needs.PREPARE-job.outputs.dockerhub_available }}" = "true" ]; then
1130+
full_image="${{ vars.DOCKERHUB_USERNAME }}/${DOCKERFILE_NAME}:${VERSION}"
1131+
registry_url="https://registry-1.docker.io/v2"
1132+
api_path="${{ vars.DOCKERHUB_USERNAME }}/${DOCKERFILE_NAME}"
1133+
registry_type="docker.io"
1134+
else
1135+
echo "Error: No public registry available for deployment"
1136+
exit 1
1137+
fi
1138+
1139+
echo "Deploying image: $full_image"
1140+
echo "Registry API: $registry_url"
1141+
echo "API path: $api_path"
1142+
1143+
# Get manifest and extract digest
1144+
echo "Fetching manifest for tag: ${VERSION}"
1145+
1146+
digest=$(curl -s -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
1147+
"$registry_url/$api_path/manifests/${VERSION}" \
1148+
| jq -r '.config.digest // empty')
1149+
1150+
if [ -z "$digest" ] || [ "$digest" = "null" ]; then
1151+
echo "Warning: Could not get digest, using placeholder"
1152+
digest="sha256:placeholder_digest_for_${VERSION}"
1153+
fi
1154+
1155+
echo "SHA256 digest: $digest"
1156+
1157+
# Set outputs
1158+
echo "full_image=$full_image" >> $GITHUB_OUTPUT
1159+
echo "registry_type=$registry_type" >> $GITHUB_OUTPUT
1160+
echo "digest=$digest" >> $GITHUB_OUTPUT
1161+
1162+
- name: Create SHPC container registry entry
1163+
run: |
1164+
set -euo pipefail
1165+
1166+
full_image="${{ steps.get_image_info.outputs.full_image }}"
1167+
registry_type="${{ steps.get_image_info.outputs.registry_type }}"
1168+
digest="${{ steps.get_image_info.outputs.digest }}"
1169+
1170+
# Create registry directory structure based on the deployed image
1171+
if [ "$registry_type" = "quay.io" ]; then
1172+
shpc_path="${SHPC_REGISTRY}/quay.io/${{ vars.QUAYIO_USERNAME }}/${DOCKERFILE_NAME}"
1173+
else
1174+
shpc_path="${SHPC_REGISTRY}/docker.io/${{ vars.DOCKERHUB_USERNAME }}/${DOCKERFILE_NAME}"
1175+
fi
1176+
1177+
echo "Creating SHPC registry entry at: $shpc_path"
1178+
1179+
# Create container.yaml content
1180+
container_yaml=$(cat <<EOF
1181+
docker: $full_image
1182+
1183+
latest:
1184+
"${VERSION}": "$digest"
1185+
tags:
1186+
"${VERSION}": "$digest"
1187+
1188+
maintainer: "@github-actions"
1189+
1190+
description: "Container for ${DOCKERFILE_NAME} version ${VERSION} - built and deployed via CI/CD"
1191+
url: "https://github.com/${GITHUB_REPOSITORY}"
1192+
EOF
1193+
)
1194+
1195+
echo "Container YAML content:"
1196+
echo "$container_yaml"
1197+
1198+
# Verify SHPC configuration before writing
1199+
echo "Verifying SHPC configuration..."
1200+
module load shpc/0.1.32
1201+
if shpc config get registry | grep -q pawsey_registry; then
1202+
echo "✓ SHPC registry is properly configured"
1203+
else
1204+
echo "Warning: SHPC registry may not be properly configured"
1205+
fi
1206+
1207+
# Switch to spack user to write to registry (spack user has write permissions)
1208+
echo "Switching to spack user to write to registry..."
1209+
sudo su - spack -c "
1210+
set -euo pipefail
1211+
mkdir -p '$shpc_path'
1212+
cat > '$shpc_path/container.yaml' <<'EOF'
1213+
$container_yaml
1214+
EOF
1215+
echo '✓ SHPC registry entry created successfully'
1216+
ls -la '$shpc_path/'
1217+
cat '$shpc_path/container.yaml'
1218+
"
1219+
1220+
echo "✅ SHPC deployment completed"
1221+
echo "Registry path: $shpc_path"
1222+
echo "Image: $full_image"
1223+
echo "Version: ${VERSION}"
1224+
echo "Digest: $digest"
1225+
10791226
SUMMARY-job:
1080-
needs: [BUILD-job, PREPARE-job, PUSH-PRIV-job, PUSH-PUBLIC-job]
1227+
needs: [BUILD-job, PREPARE-job, PUSH-PRIV-job, PUSH-PUBLIC-job, DEPLOY-job]
10811228
runs-on: ubuntu-latest
10821229
if: always() && needs.PREPARE-job.outputs.proceed_valid == 'true'
10831230
env:
@@ -1211,6 +1358,62 @@ jobs:
12111358
echo ""
12121359
fi
12131360
1361+
echo "## 🚀 SHPC Container Deployment"
1362+
echo ""
1363+
echo "| Registry Path | Image Source | Status |"
1364+
echo "|---------------|--------------|--------|"
1365+
1366+
# SHPC deployment status based on DEPLOY-job result and available registries
1367+
if [ "${{ needs.DEPLOY-job.result }}" = "success" ]; then
1368+
# Determine which registry was used for SHPC deployment
1369+
if [ "${{ needs.PREPARE-job.outputs.quayio_available }}" = "true" ]; then
1370+
echo "| \`/software/setonix/2025.08/pawsey/software/shpc/pawsey_registry/quay.io/${{ vars.QUAYIO_USERNAME }}/${{ env.DOCKERFILE_NAME }}/\` | \`quay.io/${{ vars.QUAYIO_USERNAME }}/${{ env.DOCKERFILE_NAME }}:${{ env.VERSION }}\` | ✅ Deployed |"
1371+
echo ""
1372+
echo "### SHPC Usage Commands"
1373+
echo ""
1374+
echo "Load and use the container via SHPC:"
1375+
echo "\`\`\`bash"
1376+
echo "# Load SHPC module"
1377+
echo "module load shpc/0.1.32"
1378+
echo ""
1379+
echo "# Install the container"
1380+
echo "shpc install quay.io/${{ vars.QUAYIO_USERNAME }}/${{ env.DOCKERFILE_NAME }}:${{ env.VERSION }}"
1381+
echo ""
1382+
echo "# Show available commands"
1383+
echo "shpc show quay.io/${{ vars.QUAYIO_USERNAME }}/${{ env.DOCKERFILE_NAME }}:${{ env.VERSION }}"
1384+
echo ""
1385+
echo "# Use the container"
1386+
echo "shpc run quay.io/${{ vars.QUAYIO_USERNAME }}/${{ env.DOCKERFILE_NAME }}:${{ env.VERSION }} <command>"
1387+
echo "\`\`\`"
1388+
elif [ "${{ needs.PREPARE-job.outputs.dockerhub_available }}" = "true" ]; then
1389+
echo "| \`/software/setonix/2025.08/pawsey/software/shpc/pawsey_registry/docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERFILE_NAME }}/\` | \`docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERFILE_NAME }}:${{ env.VERSION }}\` | ✅ Deployed |"
1390+
echo ""
1391+
echo "### SHPC Usage Commands"
1392+
echo ""
1393+
echo "Load and use the container via SHPC:"
1394+
echo "\`\`\`bash"
1395+
echo "# Load SHPC module"
1396+
echo "module load shpc/0.1.32"
1397+
echo ""
1398+
echo "# Install the container"
1399+
echo "shpc install docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERFILE_NAME }}:${{ env.VERSION }}"
1400+
echo ""
1401+
echo "# Show available commands"
1402+
echo "shpc show docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERFILE_NAME }}:${{ env.VERSION }}"
1403+
echo ""
1404+
echo "# Use the container"
1405+
echo "shpc run docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERFILE_NAME }}:${{ env.VERSION }} <command>"
1406+
echo "\`\`\`"
1407+
fi
1408+
elif [ "${{ needs.DEPLOY-job.result }}" = "failure" ]; then
1409+
echo "| SHPC Registry | N/A | ❌ Deployment Failed |"
1410+
elif [ "${{ needs.DEPLOY-job.result }}" = "skipped" ]; then
1411+
echo "| SHPC Registry | N/A | ⏭️ Skipped (No public registry available) |"
1412+
else
1413+
echo "| SHPC Registry | N/A | ⏸️ Not Executed |"
1414+
fi
1415+
1416+
echo ""
12141417
echo "## 📊 Job Results"
12151418
echo ""
12161419
echo "| Job | Status |"
@@ -1220,6 +1423,7 @@ jobs:
12201423
echo "| SCAN-AND-REPORT | ${{ needs['SCAN-AND-REPORT-job'].result == 'success' && '✅ Success' || (needs['SCAN-AND-REPORT-job'].result == 'skipped' && '⏭️ Skipped') || '❌ Failed' }} |"
12211424
echo "| PUSH-PRIV | ${{ needs.PUSH-PRIV-job.result == 'success' && '✅ Success' || '❌ Failed' }} |"
12221425
echo "| PUSH-PUBLIC | ${{ needs.PUSH-PUBLIC-job.result == 'success' && '✅ Success' || '❌ Failed' }} |"
1426+
echo "| DEPLOY | ${{ needs.DEPLOY-job.result == 'success' && '✅ Success' || (needs.DEPLOY-job.result == 'skipped' && '⏭️ Skipped') || '❌ Failed' }} |"
12231427
12241428
} >> "$GITHUB_STEP_SUMMARY"
12251429

x86/ex1.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#FROM ubuntu:20.04
44
FROM ubuntu:16.04
55

6-
LABEL org.opencontainers.image.version=0.0.5
6+
LABEL org.opencontainers.image.version=0.0.8
77
LABEL org.opencontainers.image.devmode=true
88

99
# # Install curl packageW

0 commit comments

Comments
 (0)