Skip to content

FIx manual launch workflow with codemagic ui  #102

@kcbuilder

Description

@kcbuilder

Got problem when trying to manual retry the workflow after having some issue in previous build

image

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
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions