Skip to content

Commit e7d04b0

Browse files
ci: update the README automatically
1 parent 5b739cb commit e7d04b0

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

.github/workflows/pytorch-dev.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Update PyTorch Templates
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
paths:
8+
- "official-templates/pytorch/**"
9+
pull_request:
10+
paths:
11+
- "official-templates/pytorch/**"
12+
workflow_dispatch:
13+
inputs:
14+
specific_template:
15+
description: "Specific template to update (leave empty to update all)"
16+
required: false
17+
type: string
18+
19+
jobs:
20+
update-templates:
21+
runs-on: ubuntu-latest-public-m
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
# Map PyTorch variants to template IDs
27+
# CUDA variants
28+
- target: 210-py310-cuda1180-devel-ubuntu2204
29+
template_id: runpod-torch-v21
30+
# Commented out for testing
31+
# - target: 240-py311-cuda1241-devel-ubuntu2204
32+
# template_id: runpod-torch-v240
33+
# - target: 220-py310-cuda1211-devel-ubuntu2204
34+
# template_id: runpod-torch-v220
35+
# - target: 211-py310-cuda1211-devel-ubuntu2204
36+
# template_id: runpod-torch-v211
37+
# - target: 201-py310-cuda1180-devel-ubuntu2204
38+
# template_id: runpod-torch
39+
# - target: 1131-py38-cuda1171-devel-ubuntu2204
40+
# template_id: runpod-torch-v1
41+
# # ROCM variants
42+
# - target: 240-py310-rocm610-ubuntu2204
43+
# template_id: runpod-torch-v240-rocm61
44+
# - target: 201-py310-rocm57-ubuntu2204
45+
# template_id: runpod-torch-v201-rocm57
46+
# - target: 201-py39-rocm61-ubuntu2004
47+
# template_id: runpod-torch-v201-rocm61
48+
# - target: 201-py38-rocm56-ubuntu2004
49+
# template_id: runpod-torch-v201-rocm56
50+
# - target: 211-py39-rocm60-ubuntu2004
51+
# template_id: runpod-torch-v211-rocm60
52+
# - target: 212-py310-rocm602-ubuntu2204
53+
# template_id: runpod-torch-v212-rocm602
54+
# - target: 212-py310-rocm61-ubuntu2204
55+
# template_id: runpod-torch-v212-rocm61
56+
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
61+
- name: Skip if specific template is set and doesn't match
62+
id: check_template
63+
run: |
64+
if [[ "${{ github.event.inputs.specific_template }}" != "" && "${{ github.event.inputs.specific_template }}" != "${{ matrix.template_id }}" ]]; then
65+
echo "skip=true" >> $GITHUB_OUTPUT
66+
else
67+
echo "skip=false" >> $GITHUB_OUTPUT
68+
fi
69+
70+
- name: Make script executable
71+
if: steps.check_template.outputs.skip != 'true'
72+
run: chmod +x official-templates/pytorch/update-template.sh
73+
74+
- name: Update template via script
75+
if: steps.check_template.outputs.skip != 'true'
76+
env:
77+
RUNPOD_API_KEY: ${{ secrets.RUNPOD_API_KEY }}
78+
run: ./official-templates/pytorch/update-template.sh ${{ matrix.template_id }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Check if template ID is provided
5+
if [ -z "$1" ]; then
6+
echo "Error: Template ID is required"
7+
echo "Usage: $0 <template_id>"
8+
exit 1
9+
fi
10+
11+
TEMPLATE_ID=$1
12+
README_PATH="official-templates/pytorch/README.md"
13+
API_KEY=$RUNPOD_API_KEY
14+
15+
# Check if API key is set
16+
if [ -z "$API_KEY" ]; then
17+
echo "Error: RUNPOD_API_KEY environment variable is not set"
18+
exit 1
19+
fi
20+
21+
# Read README content
22+
if [ ! -f "$README_PATH" ]; then
23+
echo "Error: README file not found at $README_PATH"
24+
exit 1
25+
fi
26+
27+
# Use Node.js to escape the README content for JSON
28+
README_JSON=$(node -e "console.log(JSON.stringify(require('fs').readFileSync('$README_PATH', 'utf8')))")
29+
30+
# Create GraphQL query
31+
cat << EOF > query.json
32+
{
33+
"query": "mutation AdminUpdatePodTemplate(\$input: AdminUpdatePodTemplateInput!) { adminUpdatePodTemplate(input: \$input) { id name } }",
34+
"variables": {
35+
"input": {
36+
"id": "$TEMPLATE_ID",
37+
"readme": $README_JSON
38+
}
39+
}
40+
}
41+
EOF
42+
43+
# Execute GraphQL mutation
44+
echo "Updating template $TEMPLATE_ID..."
45+
response=$(curl -s -X POST \
46+
-H "Content-Type: application/json" \
47+
-H "Authorization: Bearer $API_KEY" \
48+
-d @query.json \
49+
https://api.runpod.io/graphql)
50+
51+
# Check for errors
52+
if echo "$response" | grep -q "errors"; then
53+
echo "❌ GraphQL mutation failed for template $TEMPLATE_ID:"
54+
echo "$response"
55+
exit 1
56+
else
57+
echo "✅ GraphQL mutation successful for template $TEMPLATE_ID:"
58+
echo "$response"
59+
fi
60+
61+
# Clean up
62+
rm query.json

0 commit comments

Comments
 (0)