-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Got problem when trying to manual retry the workflow after having some issue in previous build
Prepared hack for it to update env variable based on found open pull request in github using gh
# Parse variables from env
REPO_OWNER=$(echo $CM_REPO_SLUG | cut -d'/' -f1)
REPO_NAME=$(echo $CM_REPO_SLUG | cut -d'/' -f2)
BRANCH_NAME="$CM_BRANCH"
# Auth to github using PAT
echo $GITHUB_PAT | gh auth login --with-token
# Use GitHub CLI to get the list of pull requests for the specified branch
# The '--jq' flag is used to parse the JSON response directly within the GitHub CLI
PR_ID=$(gh pr list --repo $REPO_OWNER/$REPO_NAME --head "$BRANCH_NAME" --state open --json number --jq '.[0].number')
if [ "$PR_ID" != "null" ]; then
echo "Pull Request ID for branch '$BRANCH_NAME' is $PR_ID"
# Set the pull request ID as an environment variable
echo "CM_PULL_REQUEST_NUMBER=$PR_ID" >> $CM_ENV
else
echo "No open pull request found for branch '$BRANCH_NAME'"
exit 0
fi
With using it we solving problem with not idempotent behavior

Metadata
Metadata
Assignees
Labels
No labels
