Skip to content

Commit e329263

Browse files
committed
trying fix
1 parent da11975 commit e329263

File tree

1 file changed

+42
-9
lines changed

1 file changed

+42
-9
lines changed

.github/workflows/update-test-durations.yml

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,50 @@ jobs:
8080
- name: Latest run-id from repository
8181
run: |
8282
set -euo pipefail
83-
if [ "${{ inputs.path }}" == "localstack-pro" ]; then
84-
WF_FILE=".github/workflows/aws_main.yml"
83+
84+
# trying fix
85+
REPO_PATH="${{ inputs.path }}" # 'localstack' or 'localstack-pro'
86+
if [ "$REPO_PATH" = "localstack-pro" ]; then
87+
WF_FILE=".github/workflows/aws_main.yml" # underscore in Pro
8588
else
86-
WF_FILE=".github/workflows/aws-main.yml"
89+
WF_FILE=".github/workflows/aws-main.yml" # hyphen in Community
90+
fi
91+
92+
# Authenticated list of workflows (avoid 404/ratelimit/private misses)
93+
wfs_url="https://api.github.com/repos/localstack/${REPO_PATH}/actions/workflows?per_page=100"
94+
latest_workflow_id=$(
95+
curl -sS -H "Authorization: Bearer $GH_TOKEN" "$wfs_url" | jq -r --arg wf "$WF_FILE" '.workflows[] | select(.path==$wf) | .id' | head -n1
96+
)
97+
98+
if [ -z "${latest_workflow_id:-}" ]; then
99+
echo "::error::Could not find workflow by path '$WF_FILE' in localstack/${REPO_PATH}"
100+
echo "Available workflows (name | path):"
101+
curl -sS -H "Authorization: Bearer $GH_TOKEN" "$wfs_url" \
102+
| jq -r '.workflows[] | "\(.name) | \(.path)"'
103+
exit 1
87104
fi
88-
89-
latest_workflow_id=$(curl -s https://api.github.com/repos/localstack/${{ inputs.path }}/actions/workflows \
90-
| jq '.workflows[] | select(.path=="$WF_FILE").id')
91-
latest_run_id=$(curl -s \
92-
"https://api.github.com/repos/localstack/${{ inputs.path }}/actions/workflows/${latest_workflow_id}/runs?branch=main&status=success&per_page=30" \
93-
| jq '[.workflow_runs[] | select(.event == "schedule")][0].id')
105+
106+
runs_url="https://api.github.com/repos/localstack/${REPO_PATH}/actions/workflows/${latest_workflow_id}/runs?branch=main&status=success&per_page=50"
107+
latest_run_id=$(
108+
curl -sS -H "Authorization: Bearer $GH_TOKEN" "$runs_url" | jq -r '[.workflow_runs[] | select(.event=="schedule")][0].id // empty'
109+
)
110+
111+
if [ -z "${latest_run_id:-}" ]; then
112+
echo "::error::No successful scheduled runs found for '$WF_FILE' on branch 'main'"
113+
exit 1
114+
fi
115+
116+
# if [ "${{ inputs.path }}" == "localstack-pro" ]; then
117+
# WF_FILE=".github/workflows/aws_main.yml"
118+
# else
119+
# WF_FILE=".github/workflows/aws-main.yml"
120+
# fi
121+
#
122+
# latest_workflow_id=$(curl -s https://api.github.com/repos/localstack/${{ inputs.path }}/actions/workflows \
123+
# | jq '.workflows[] | select(.path=="$WF_FILE").id')
124+
# latest_run_id=$(curl -s \
125+
# "https://api.github.com/repos/localstack/${{ inputs.path }}/actions/workflows/${latest_workflow_id}/runs?branch=main&status=success&per_page=30" \
126+
# | jq '[.workflow_runs[] | select(.event == "schedule")][0].id')
94127
echo "Latest run: https://github.com/localstack/${{ inputs.path }}/actions/runs/${latest_run_id}"
95128
echo "AWS_MAIN_LATEST_SCHEDULED_RUN_ID=${latest_run_id}" >> $GITHUB_ENV
96129

0 commit comments

Comments
 (0)