Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx manual launch workflow with codemagic ui #102

Open
kcbuilder opened this issue Nov 11, 2023 · 2 comments
Open

FIx manual launch workflow with codemagic ui #102

kcbuilder opened this issue Nov 11, 2023 · 2 comments

Comments

@kcbuilder
Copy link

kcbuilder commented Nov 11, 2023

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

@kcbuilder
Copy link
Author

kcbuilder commented Nov 11, 2023

@nilsreichardt not an issue really, but decided to share it here, can be helpful for organizing smoothless dev experience

ps, thanks for package, it is awesome

@nilsreichardt
Copy link
Owner

Nice, thanks for the tip! This is something I could integrate into the CLI itself. As it is today, I can check if CM_PULL_REQUEST_NUMBER is empty and if yes, also check with gh CLI and only if this also empty then throw an exception that no pull request could be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants