fix: indent heredoc content to satisfy YAML block scalar parser

YAML ends a block scalar when it sees content less indented than
the first content line. The JSON heredoc at column 0 caused the
parser to bail out mid-block. Indenting to 8 spaces keeps it inside
the run: | scalar; YAML strips that indentation before handing the
script to the shell, so the NOMAD_EOF terminator lands at column 0
as required.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Christopher Mühl 2026-02-17 11:06:04 +01:00
parent 22ad13e061
commit 76c0b483c8
No known key found for this signature in database
GPG key ID: 925AC7D69955293F

View file

@ -79,101 +79,101 @@ runs:
shell: bash shell: bash
run: | run: |
cat > /tmp/deploy-${{ inputs.site-name }}.nomad.json <<'NOMAD_EOF' cat > /tmp/deploy-${{ inputs.site-name }}.nomad.json <<'NOMAD_EOF'
{
"Job": {
"ID": "${{ inputs.site-name }}",
"Name": "${{ inputs.site-name }}",
"Type": "service",
"Datacenters": ["contabo"],
"Constraints": [{
"LTarget": "${node.unique.name}",
"RTarget": "alvin",
"Operand": "="
}],
"TaskGroups": [{
"Name": "web",
"Count": 1,
"Networks": [{
"Mode": "bridge",
"DynamicPorts": [{
"Label": "http",
"To": 8080
}]
}],
"Services": [{
"Name": "${{ inputs.site-name }}",
"PortLabel": "http",
"Provider": "nomad",
"Tags": [
"traefik.enable=true",
"traefik.http.routers.${{ inputs.site-name }}.rule=${{ inputs.traefik-rule }}",
"traefik.http.routers.${{ inputs.site-name }}.entrypoints=websecure",
"traefik.http.routers.${{ inputs.site-name }}.tls.certresolver=letsencrypt"
]
}],
"Volumes": {
"site-data": {
"Type": "host",
"Source": "site-data",
"ReadOnly": false
}
},
"Tasks": [
{ {
"Name": "fetch", "Job": {
"Driver": "docker", "ID": "${{ inputs.site-name }}",
"Lifecycle": { "Name": "${{ inputs.site-name }}",
"Hook": "prestart", "Type": "service",
"Sidecar": false "Datacenters": ["contabo"],
}, "Constraints": [{
"Config": { "LTarget": "${node.unique.name}",
"image": "nixos/nix:latest", "RTarget": "alvin",
"command": "/bin/sh", "Operand": "="
"args": [ }],
"-c", "TaskGroups": [{
"nix copy --from 's3://nix-cache?endpoint=${{ inputs.s3-endpoint }}&scheme=https' '${STORE_PATH}' && cp -r ${STORE_PATH}/* /alloc/data/" "Name": "web",
] "Count": 1,
}, "Networks": [{
"Env": { "Mode": "bridge",
"AWS_ACCESS_KEY_ID": "${{ env.S3_ACCESS_KEY }}", "DynamicPorts": [{
"AWS_SECRET_ACCESS_KEY": "${{ env.S3_SECRET_KEY }}", "Label": "http",
"STORE_PATH": "${{ env.STORE_PATH }}" "To": 8080
}, }]
"VolumeMounts": [{ }],
"Volume": "site-data", "Services": [{
"Destination": "/alloc/data" "Name": "${{ inputs.site-name }}",
}], "PortLabel": "http",
"Resources": { "Provider": "nomad",
"CPU": 200, "Tags": [
"MemoryMB": 256 "traefik.enable=true",
} "traefik.http.routers.${{ inputs.site-name }}.rule=${{ inputs.traefik-rule }}",
}, "traefik.http.routers.${{ inputs.site-name }}.entrypoints=websecure",
{ "traefik.http.routers.${{ inputs.site-name }}.tls.certresolver=letsencrypt"
"Name": "server", ]
"Driver": "docker", }],
"Config": { "Volumes": {
"image": "joseluisq/static-web-server:2", "site-data": {
"ports": ["http"] "Type": "host",
}, "Source": "site-data",
"Env": { "ReadOnly": false
"SERVER_ROOT": "/var/www", }
"SERVER_LOG_LEVEL": "info" },
}, "Tasks": [
"VolumeMounts": [{ {
"Volume": "site-data", "Name": "fetch",
"Destination": "/var/www", "Driver": "docker",
"ReadOnly": true "Lifecycle": {
}], "Hook": "prestart",
"Resources": { "Sidecar": false
"CPU": 100, },
"MemoryMB": 64 "Config": {
"image": "nixos/nix:latest",
"command": "/bin/sh",
"args": [
"-c",
"nix copy --from 's3://nix-cache?endpoint=${{ inputs.s3-endpoint }}&scheme=https' '${STORE_PATH}' && cp -r ${STORE_PATH}/* /alloc/data/"
]
},
"Env": {
"AWS_ACCESS_KEY_ID": "${{ env.S3_ACCESS_KEY }}",
"AWS_SECRET_ACCESS_KEY": "${{ env.S3_SECRET_KEY }}",
"STORE_PATH": "${{ env.STORE_PATH }}"
},
"VolumeMounts": [{
"Volume": "site-data",
"Destination": "/alloc/data"
}],
"Resources": {
"CPU": 200,
"MemoryMB": 256
}
},
{
"Name": "server",
"Driver": "docker",
"Config": {
"image": "joseluisq/static-web-server:2",
"ports": ["http"]
},
"Env": {
"SERVER_ROOT": "/var/www",
"SERVER_LOG_LEVEL": "info"
},
"VolumeMounts": [{
"Volume": "site-data",
"Destination": "/var/www",
"ReadOnly": true
}],
"Resources": {
"CPU": 100,
"MemoryMB": 64
}
}
]
}]
} }
} }
] NOMAD_EOF
}]
}
}
NOMAD_EOF
nomad job run -json /tmp/deploy-${{ inputs.site-name }}.nomad.json nomad job run -json /tmp/deploy-${{ inputs.site-name }}.nomad.json