Skip to content

Commit

Permalink
hardcode run-id
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartz committed Apr 17, 2024
1 parent d7a832e commit 95b5778
Showing 1 changed file with 44 additions and 44 deletions.
88 changes: 44 additions & 44 deletions .github/workflows/publish_charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,50 +113,50 @@ jobs:
if: ${{ github.event_name == 'push' }}
shell: bash
run: |
# Get commit info
TREE_SHA=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/commits/${GITHUB_SHA} \
--jq '.commit.tree.sha')
# Get workflow run id from this specific tree id, paginate until found
TOTAL_COUNT=$(gh api \
--method GET \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/actions/runs \
-f status=completed \
-f event=pull_request | jq ".total_count")
PER_PAGE=100
MAX_PAGES=$(( (TOTAL_COUNT + 99) / $PER_PAGE ))
PAGE=1
while true; do
RESULT=$( gh api \
--method GET \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/actions/runs \
-f page=$PAGE \
-f per_page=$PER_PAGE \
-f status=completed \
-f event=pull_request \
--jq "[
.workflow_runs[]
| select(.path == \".github/workflows/integration_test.yaml\")
| select(.head_commit.tree_id == \"$TREE_SHA\")
] | max_by(.updated_at) | .id"
)
if [[ -n $RESULT ]]; then
RUN_ID=$RESULT
break
fi
if [[ "PAGE" -eq "$MAX_PAGES" ]]; then
echo "::error::No workflow run id found for specific tree id"
exit 1
fi
((PAGE++))
done
# # Get commit info
# TREE_SHA=$(gh api \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# /repos/${{ github.repository }}/commits/${GITHUB_SHA} \
# --jq '.commit.tree.sha')
# # Get workflow run id from this specific tree id, paginate until found
# TOTAL_COUNT=$(gh api \
# --method GET \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# /repos/${{ github.repository }}/actions/runs \
# -f status=completed \
# -f event=pull_request | jq ".total_count")
# PER_PAGE=100
# MAX_PAGES=$(( (TOTAL_COUNT + 99) / $PER_PAGE ))
# PAGE=1
# while true; do
# RESULT=$( gh api \
# --method GET \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# /repos/${{ github.repository }}/actions/runs \
# -f page=$PAGE \
# -f per_page=$PER_PAGE \
# -f status=completed \
# -f event=pull_request \
# --jq "[
# .workflow_runs[]
# | select(.path == \".github/workflows/integration_test.yaml\")
# | select(.head_commit.tree_id == \"$TREE_SHA\")
# ] | max_by(.updated_at) | .id"
# )
#
# if [[ -n $RESULT ]]; then
# RUN_ID=$RESULT
# break
# fi
# if [[ "PAGE" -eq "$MAX_PAGES" ]]; then
# echo "::error::No workflow run id found for specific tree id"
# exit 1
# fi
# ((PAGE++))
# done

echo "RUN_ID=8611736651" >> $GITHUB_ENV
env:
Expand Down

0 comments on commit 95b5778

Please sign in to comment.