Skip to content

Commit 559eebc

Browse files
committed
update workflow to python runners
1 parent e05de97 commit 559eebc

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

.github/workflows/deploy-ecosystem.yml

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,54 @@ jobs:
5252
with:
5353
fetch-depth: 0
5454

55-
- name: Install yq
56-
uses: mikefarah/yq@v4.44.3
57-
58-
- name: Convert deployment config YAML to JSON
55+
- name: Parse deployment config (YAML -> JSON) with Python
5956
id: config
57+
shell: bash
6058
run: |
61-
yq -o=json '.'
62-
yq -o=json '.' .github/deploy-ecosystem-configs.yml > /tmp/deploy-config.json
59+
set -euo pipefail
60+
61+
# Convert YAML to JSON. Prefer PyYAML if present; install locally if missing.
62+
python3 - << 'PY' > /tmp/deploy-config.json
63+
import json, sys
64+
from pathlib import Path
65+
66+
config_path = Path(".github/deploy-ecosystem-configs.yml")
67+
if not config_path.exists():
68+
print(f"Config file not found: {config_path}", file=sys.stderr)
69+
sys.exit(1)
70+
71+
try:
72+
import yaml # type: ignore
73+
except Exception:
74+
# If PyYAML isn't available, signal caller to install it.
75+
print("__NEED_PYYAML__", file=sys.stderr)
76+
sys.exit(2)
77+
78+
data = yaml.safe_load(config_path.read_text(encoding="utf-8"))
79+
print(json.dumps(data))
80+
PY
81+
82+
# If PyYAML was missing, install it and retry once.
83+
if grep -q "__NEED_PYYAML__" /tmp/deploy-config.json 2>/dev/null; then
84+
true
85+
fi
86+
87+
# The above approach prints the marker to stderr and exits 2, so handle that:
88+
if [ "${PIPESTATUS[0]:-0}" -ne 0 ]; then
89+
echo "PyYAML not found; installing with pip (user install)..."
90+
python3 -m pip install --user pyyaml
91+
python3 - << 'PY' > /tmp/deploy-config.json
92+
import json
93+
from pathlib import Path
94+
import yaml # type: ignore
95+
96+
config_path = Path(".github/deploy-ecosystem-configs.yml")
97+
data = yaml.safe_load(config_path.read_text(encoding="utf-8"))
98+
print(json.dumps(data))
99+
PY
100+
fi
101+
102+
# Expose JSON as a multiline output safely
63103
echo "config_json<<EOF" >> "$GITHUB_OUTPUT"
64104
cat /tmp/deploy-config.json >> "$GITHUB_OUTPUT"
65105
echo "EOF" >> "$GITHUB_OUTPUT"

.secrets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
VERCEL_TOKEN=XQuR5T8IS00tGUqzSD6DjdNq
2+
VERCEL_ORG_ID=team_Rkpr79hpkdN1SRUfFXjMlW5H
3+
GITHUB_TOKEN=test

0 commit comments

Comments
 (0)