File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed
Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 5151 - name : Get Hugo Version
5252 id : hugo-version
5353 run : |
54- VERSION=$(grep "hugo_version" hugoblox.yaml | awk '{print $2}' | tr -d "'\""")
54+ # Install pinned yq version for robust YAML parsing
55+ YQ_VERSION="v4.44.1"
56+ if ! wget -q --tries=3 --waitretry=1 -O /tmp/yq \
57+ "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"; then
58+ echo "::error::Failed to download yq"
59+ exit 1
60+ fi
61+ sudo mv /tmp/yq /usr/local/bin/yq
62+ sudo chmod +x /usr/local/bin/yq
63+
64+ # Read hugo_version from hugoblox.yaml
65+ VERSION=$(yq '.hugo_version // ""' hugoblox.yaml 2>/dev/null | grep -v '^null$' || true)
66+
67+ # Fallback to a known stable version if not specified
68+ DEFAULT_VERSION="0.154.5"
69+ VERSION=${VERSION:-$DEFAULT_VERSION}
70+
71+ # Validate version format (basic check)
72+ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
73+ echo "::warning::Invalid hugo_version format '$VERSION', using default $DEFAULT_VERSION"
74+ VERSION="$DEFAULT_VERSION"
75+ fi
76+
5577 echo "HUGO_VERSION=$VERSION" >> $GITHUB_ENV
78+ echo "Using Hugo version: $VERSION"
5679
5780 - name : Install dependencies
5881 run : |
Original file line number Diff line number Diff line change 3434 - name : Check deploy host
3535 id : check
3636 run : |
37+ # Install pinned yq version for robust YAML parsing
38+ YQ_VERSION="v4.44.1"
39+ if ! wget -q --tries=3 --waitretry=1 -O /tmp/yq \
40+ "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"; then
41+ echo "::error::Failed to download yq"
42+ exit 1
43+ fi
44+ sudo mv /tmp/yq /usr/local/bin/yq
45+ sudo chmod +x /usr/local/bin/yq
46+
3747 # Read deploy.host from hugoblox.yaml, default to github-pages
38- HOST=$(grep -A5 "^deploy:" hugoblox.yaml 2>/dev/null | grep "host:" | awk '{print $2} ' | tr -d "'\""" || echo "github-pages" )
48+ HOST=$(yq '.deploy.host // ""' hugoblox.yaml 2>/dev/null | grep -v '^null$ ' || true )
3949 HOST=${HOST:-github-pages}
50+
51+ # Validate known hosts
52+ if [[ ! "$HOST" =~ ^(github-pages|netlify|vercel|cloudflare|none)$ ]]; then
53+ echo "::warning::Unknown deploy host '$HOST', defaulting to github-pages"
54+ HOST="github-pages"
55+ fi
56+
4057 echo "host=$HOST" >> $GITHUB_OUTPUT
4158 echo "Deployment target: $HOST"
4259
You can’t perform that action at this time.
0 commit comments