Skip to content

Commit fdb6926

Browse files
authored
Merge pull request #515 from webstackdev/hotfix/input-parsing-in-action-workflows
Hotfix/input parsing in action workflows
2 parents 073d12e + cf86010 commit fdb6926

11 files changed

Lines changed: 177 additions & 37 deletions

File tree

.cache/pages.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@
2222
"contact",
2323
"offline",
2424
{
25-
"privacy": ["my-data"]
25+
"privacy": [
26+
"my-data"
27+
]
2628
},
2729
{
28-
"services": ["consulting", "overview", "web-development"]
30+
"services": [
31+
"consulting",
32+
"overview",
33+
"web-development"
34+
]
2935
},
3036
{
3137
"tags": [
@@ -40,4 +46,4 @@
4046
"typescript"
4147
]
4248
}
43-
]
49+
]

.github/actions/check-prerequisites-and-locate-build-artifact/src/main.py

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,31 @@ class WorkflowDescriptor:
1616
label: str
1717

1818

19+
def get_input_compat(name: str, *, required: bool = False) -> str:
20+
"""Reads action inputs while tolerating runner normalization.
21+
22+
Unit tests for these actions frequently monkeypatch `core.get_input`.
23+
We prefer `core.get_input` first, then fall back to direct env lookups
24+
that accept both hyphen and underscore variants.
25+
"""
26+
27+
value = core.get_input(name, required=False)
28+
if value:
29+
return value.strip()
30+
31+
normalized = name.replace(" ", "_").upper()
32+
candidates = {normalized, normalized.replace("-", "_"), normalized.replace("_", "-")}
33+
for candidate in candidates:
34+
env_value = os.getenv(f"INPUT_{candidate}", "")
35+
if env_value:
36+
return env_value.strip()
37+
38+
if required:
39+
# Preserve the same error message format as actions_toolkit.
40+
return core.get_input(name, required=True)
41+
return ""
42+
43+
1944
def get_github_api_base_url() -> str:
2045
raw = (os.environ.get("GITHUB_API_URL") or "https://api.github.com").strip()
2146
parsed = urlparse(raw)
@@ -114,17 +139,17 @@ def find_artifact_download_url(
114139

115140
def run() -> None:
116141
try:
117-
token = core.get_input("github-token", required=True)
118-
sha = core.get_input("sha", required=True).strip()
119-
trigger_event = core.get_input("trigger-event")
120-
head_branch = core.get_input("head-branch")
121-
is_fork = (core.get_input("is-fork") or "false").strip().lower() == "true"
122-
skip_hotfix = (core.get_input("skip-hotfix") or "false").strip().lower() == "true"
123-
skip_forks = (core.get_input("skip-forks") or "false").strip().lower() == "true"
124-
require_trigger_event = (core.get_input("require-trigger-event") or "").strip()
125-
build_workflow_file = core.get_input("build-workflow-file", required=True).strip()
126-
artifact_name = core.get_input("artifact-name", required=True).strip()
127-
required_workflows = parse_required_workflows(core.get_input("required-workflows-json", required=True))
142+
token = get_input_compat("github-token", required=True)
143+
sha = get_input_compat("sha", required=True).strip()
144+
trigger_event = get_input_compat("trigger-event")
145+
head_branch = get_input_compat("head-branch")
146+
is_fork = (get_input_compat("is-fork") or "false").strip().lower() == "true"
147+
skip_hotfix = (get_input_compat("skip-hotfix") or "false").strip().lower() == "true"
148+
skip_forks = (get_input_compat("skip-forks") or "false").strip().lower() == "true"
149+
require_trigger_event = (get_input_compat("require-trigger-event") or "").strip()
150+
build_workflow_file = get_input_compat("build-workflow-file", required=True).strip()
151+
artifact_name = get_input_compat("artifact-name", required=True).strip()
152+
required_workflows = parse_required_workflows(get_input_compat("required-workflows-json", required=True))
128153

129154
if require_trigger_event and trigger_event and trigger_event != require_trigger_event:
130155
core.notice(

.github/actions/create-github-deployment-preview/src/main.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
from actions_toolkit import core
88

99

10+
def get_input_compat(name: str, *, required: bool = False) -> str:
11+
value = core.get_input(name, required=False)
12+
if value:
13+
return value.strip()
14+
15+
normalized = name.replace(" ", "_").upper()
16+
candidates = {normalized, normalized.replace("-", "_"), normalized.replace("_", "-")}
17+
for candidate in candidates:
18+
env_value = os.getenv(f"INPUT_{candidate}", "")
19+
if env_value:
20+
return env_value.strip()
21+
22+
if required:
23+
return core.get_input(name, required=True)
24+
return ""
25+
26+
1027
def get_github_api_base_url() -> str:
1128
raw = (os.environ.get("GITHUB_API_URL") or "https://api.github.com").strip()
1229
parsed = urlparse(raw)
@@ -17,8 +34,8 @@ def get_github_api_base_url() -> str:
1734

1835
def run() -> None:
1936
try:
20-
token = core.get_input("github-token", required=True)
21-
sha = core.get_input("sha", required=True).strip()
37+
token = get_input_compat("github-token", required=True)
38+
sha = get_input_compat("sha", required=True).strip()
2239

2340
repo_full = (os.environ.get("GITHUB_REPOSITORY") or "").strip()
2441
if "/" not in repo_full:

.github/actions/create-github-deployment-production/src/main.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
from actions_toolkit import core
88

99

10+
def get_input_compat(name: str, *, required: bool = False) -> str:
11+
value = core.get_input(name, required=False)
12+
if value:
13+
return value.strip()
14+
15+
normalized = name.replace(" ", "_").upper()
16+
candidates = {normalized, normalized.replace("-", "_"), normalized.replace("_", "-")}
17+
for candidate in candidates:
18+
env_value = os.getenv(f"INPUT_{candidate}", "")
19+
if env_value:
20+
return env_value.strip()
21+
22+
if required:
23+
return core.get_input(name, required=True)
24+
return ""
25+
26+
1027
def get_github_api_base_url() -> str:
1128
raw = (os.environ.get("GITHUB_API_URL") or "https://api.github.com").strip()
1229
parsed = urlparse(raw)
@@ -17,8 +34,8 @@ def get_github_api_base_url() -> str:
1734

1835
def run() -> None:
1936
try:
20-
token = core.get_input("github-token", required=True)
21-
sha = core.get_input("sha", required=True).strip()
37+
token = get_input_compat("github-token", required=True)
38+
sha = get_input_compat("sha", required=True).strip()
2239

2340
repo_full = (os.environ.get("GITHUB_REPOSITORY") or "").strip()
2441
if "/" not in repo_full:

.github/actions/download-build-artifact/src/main.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212
from actions_toolkit import core
1313

1414

15+
def get_input_compat(name: str, *, required: bool = False) -> str:
16+
value = core.get_input(name, required=False)
17+
if value:
18+
return value.strip()
19+
20+
normalized = name.replace(" ", "_").upper()
21+
candidates = {normalized, normalized.replace("-", "_"), normalized.replace("_", "-")}
22+
for candidate in candidates:
23+
env_value = os.getenv(f"INPUT_{candidate}", "")
24+
if env_value:
25+
return env_value.strip()
26+
27+
if required:
28+
return core.get_input(name, required=True)
29+
return ""
30+
31+
1532
def get_github_api_base_url() -> str:
1633
raw = (os.environ.get("GITHUB_API_URL") or "https://api.github.com").strip()
1734
parsed = urlparse(raw)
@@ -27,8 +44,8 @@ def is_allowed_fetch_url(url: str, allowed_hosts: set[str]) -> bool:
2744

2845
def run() -> None:
2946
try:
30-
token = core.get_input("github-token", required=True)
31-
download_url = core.get_input("artifact-download-url", required=True).strip()
47+
token = get_input_compat("github-token", required=True)
48+
download_url = get_input_compat("artifact-download-url", required=True).strip()
3249

3350
allowed_hosts = {urlparse(get_github_api_base_url()).hostname}
3451
if not is_allowed_fetch_url(download_url, allowed_hosts):

.github/actions/mark-deployment-in-progress/src/main.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
from actions_toolkit import core
88

99

10+
def get_input_compat(name: str, *, required: bool = False) -> str:
11+
value = core.get_input(name, required=False)
12+
if value:
13+
return value.strip()
14+
15+
normalized = name.replace(" ", "_").upper()
16+
candidates = {normalized, normalized.replace("-", "_"), normalized.replace("_", "-")}
17+
for candidate in candidates:
18+
env_value = os.getenv(f"INPUT_{candidate}", "")
19+
if env_value:
20+
return env_value.strip()
21+
22+
if required:
23+
return core.get_input(name, required=True)
24+
return ""
25+
26+
1027
def get_github_api_base_url() -> str:
1128
raw = (os.environ.get("GITHUB_API_URL") or "https://api.github.com").strip()
1229
parsed = urlparse(raw)
@@ -17,9 +34,9 @@ def get_github_api_base_url() -> str:
1734

1835
def run() -> None:
1936
try:
20-
token = core.get_input("github-token", required=True)
21-
deployment_id = core.get_input("deployment-id", required=True).strip()
22-
description = core.get_input("description", required=True).strip()
37+
token = get_input_compat("github-token", required=True)
38+
deployment_id = get_input_compat("deployment-id", required=True).strip()
39+
description = get_input_compat("description", required=True).strip()
2340

2441
repo_full = (os.environ.get("GITHUB_REPOSITORY") or "").strip()
2542
if "/" not in repo_full:

.github/actions/update-deployment-status/src/main.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
from actions_toolkit import core
88

99

10+
def get_input_compat(name: str, *, required: bool = False) -> str:
11+
value = core.get_input(name, required=False)
12+
if value:
13+
return value.strip()
14+
15+
normalized = name.replace(" ", "_").upper()
16+
candidates = {normalized, normalized.replace("-", "_"), normalized.replace("_", "-")}
17+
for candidate in candidates:
18+
env_value = os.getenv(f"INPUT_{candidate}", "")
19+
if env_value:
20+
return env_value.strip()
21+
22+
if required:
23+
return core.get_input(name, required=True)
24+
return ""
25+
26+
1027
def get_github_api_base_url() -> str:
1128
raw = (os.environ.get("GITHUB_API_URL") or "https://api.github.com").strip()
1229
parsed = urlparse(raw)
@@ -17,12 +34,12 @@ def get_github_api_base_url() -> str:
1734

1835
def run() -> None:
1936
try:
20-
token = core.get_input("github-token", required=True)
21-
deployment_id = core.get_input("deployment-id", required=True).strip()
22-
exit_code = int(core.get_input("exit-code", required=True).strip() or "1")
23-
environment_url = (core.get_input("environment-url") or "").strip()
24-
success_description = core.get_input("success-description", required=True).strip()
25-
failure_description = core.get_input("failure-description", required=True).strip()
37+
token = get_input_compat("github-token", required=True)
38+
deployment_id = get_input_compat("deployment-id", required=True).strip()
39+
exit_code = int(get_input_compat("exit-code", required=True).strip() or "1")
40+
environment_url = (get_input_compat("environment-url") or "").strip()
41+
success_description = get_input_compat("success-description", required=True).strip()
42+
failure_description = get_input_compat("failure-description", required=True).strip()
2643

2744
repo_full = (os.environ.get("GITHUB_REPOSITORY") or "").strip()
2845
if "/" not in repo_full:

.github/workflows/cron.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16-
ping:
16+
ping-production:
1717
name: Ping Turso Production DB
1818
runs-on: ubuntu-latest
19+
environment: production
1920

2021
steps:
2122
- name: Checkout repository
@@ -33,5 +34,29 @@ jobs:
3334
- name: Execute keep-alive query
3435
uses: './.github/actions/keep-alive'
3536
with:
36-
astro-db-remote-url: ${{ secrets.ASTRO_DB_REMOTE_URL }}
37+
astro-db-remote-url: ${{ vars.ASTRO_DB_REMOTE_URL }}
38+
astro-db-app-token: ${{ secrets.ASTRO_DB_APP_TOKEN }}
39+
40+
ping-preview:
41+
name: Ping Turso Preview DB
42+
runs-on: ubuntu-latest
43+
environment: preview
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v6.0.1
48+
49+
- name: Setup Python
50+
uses: actions/setup-python@v6.1.0
51+
with:
52+
python-version: '3.13'
53+
cache: 'pip'
54+
55+
- name: Install Python dependencies
56+
run: python3 -m pip install -r requirements.txt
57+
58+
- name: Execute keep-alive query
59+
uses: './.github/actions/keep-alive'
60+
with:
61+
astro-db-remote-url: ${{ vars.ASTRO_DB_REMOTE_URL }}
3762
astro-db-app-token: ${{ secrets.ASTRO_DB_APP_TOKEN }}

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated file
2+
.cache/pages.json

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,16 @@
3636
"containers:logs": "FORCE_COLOR=1 docker compose --env-file test/containers/.env -f test/containers/docker-compose.e2e.yml logs -f",
3737
"dev": "npm run sync && cross-env NODE_ENV=development FORCE_COLOR=1 npx astro dev",
3838
"dev:env": "FORCE_COLOR=1 dotenv -e .env.development -- npm run dev",
39-
"format": "npm run format:json && npm run format:code && npm run format:style",
39+
"format": "npm run format:code && npm run format:style",
4040
"format:code": "FORCE_COLOR=1 npx prettier --write \"@types/**/*.{js,ts}\" \"src/**/*.{js,ts,tsx,astro}\" --plugin=prettier-plugin-astro",
41-
"format:json": "FORCE_COLOR=1 npx prettier --write '**/*.json' --cache --ignore-path .gitignore",
4241
"format:style": "FORCE_COLOR=1 npx stylelint --fix \"src/**/*.{css,astro}\"",
4342
"lint": "npm run lint:base && npm run check",
44-
"lint:actions": "FORCE_COLOR=1 npx node-actionlint && FORCE_COLOR=1 python3 -m pylint $(find .github/actions -type f -path '*/src/*.py')",
4543
"lint:base": "npm run lint:json && npm run lint:style && npm run lint:tsc:check && npm run lint:code && npm run lint:actions && npm run lint:inclusive-language",
44+
"lint:actions": "FORCE_COLOR=1 npx node-actionlint && FORCE_COLOR=1 python3 -m pylint $(find .github/actions -type f -path '*/src/*.py')",
4645
"lint:code": "npx eslint \"@types/**/*.{js,ts}\" \"src/**/*.{js,ts,tsx,astro}\" \"test/**/*.{js,ts,tsx,astro}\"",
4746
"lint:inclusive-language": "npx alex src/content",
47+
"lint:json": "FORCE_COLOR=1 npx prettier '**/*.json' --cache --ignore-path .gitignore",
4848
"lint:md": "FORCE_COLOR=1 npx markdownlint-cli2 \"**/*.{md,mdx}\" \"!**/node_modules/**\" \"!**/dist/**\" \"!**/.astro/**\" \"!**/dev-dist/**\" \"!**/__blobstorage__/**\"",
49-
"lint:json": "FORCE_COLOR=1 npx prettier --write '**/*.json' --cache --ignore-path .gitignore",
5049
"lint:style": "FORCE_COLOR=1 npx stylelint \"src/**/*.{css,astro}\"",
5150
"lint:tsc:check": "npm run sync && tsc --noEmit -p tsconfig.json --pretty false",
5251
"sync": "FORCE_COLOR=1 npx astro sync",

0 commit comments

Comments
 (0)