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

Improve autoupdate round 2 #37

Merged
merged 5 commits into from
Sep 24, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ jobs:
# We cannot use the -A option of `gh pr list` because the PR author changes with the Personal Access Token used,
# so we filter on the 3rd output field (headRefName, i.e. remote_repository:branch).
if gh_pr_list_out=$(gh pr list --search "head:$REPO" | grep -P "^\d+\t[^\t]+\tplanemo-autoupdate:$REPO\t"); then
OLD_TITLE=$(echo "$gh_pr_list_out" | cut -f 2)
OLD_TITLE=$(echo "$gh_pr_list_out" | cut -f 2 | head -n 1)
lldelisle marked this conversation as resolved.
Show resolved Hide resolved
PR_EXISTS=1
PR_NUMBER=$(echo "$gh_pr_list_out" | cut -f 1)
PR_NUMBER=$(echo "$gh_pr_list_out" | cut -f 1 | head -n 1)
lldelisle marked this conversation as resolved.
Show resolved Hide resolved
PR_STATUS="OPENED"
echo "PR exists and is opened"
DIFF_BRANCH="origin/$REPO"
else
# Check if a closed PR exists with the same title
if gh_pr_list_out=$(gh pr list --search "is:closed is:unmerged '$TITLE' in:title" | grep -P "^\d+\t[^\t]+\tplanemo-autoupdate:"); then
lldelisle marked this conversation as resolved.
Show resolved Hide resolved
echo "Found a closed PR with title: $TITLE"
OLD_TITLE=$(echo "$gh_pr_list_out" | cut -f 2)
OLD_TITLE=$(echo "$gh_pr_list_out" | cut -f 2 | head -n 1)
lldelisle marked this conversation as resolved.
Show resolved Hide resolved
PR_EXISTS=1
PR_NUMBER=$(echo "$gh_pr_list_out" | cut -f 1)
PR_NUMBER=$(echo "$gh_pr_list_out" | cut -f 1 | head -n 1)
lldelisle marked this conversation as resolved.
Show resolved Hide resolved
PR_STATUS="CLOSED"
if [ "$(git branch -a --list "origin/$REPO")" != "" ]; then
# The branch still exists and the PR should be reopened only if there is a new change
Expand Down Expand Up @@ -197,6 +197,10 @@ jobs:
echo "Creating a PR..."
gh pr create --base "${{ matrix.upstream_repo_branch }}" --head "planemo-autoupdate:$REPO" --title "$TITLE" --repo "${{ matrix.upstream_repo_owner}}/${{ matrix.upstream_repo_name }}" --body-file "${{ github.workspace }}/body.txt"
fi
else
echo "No changes compared to current PR"
lldelisle marked this conversation as resolved.
Show resolved Hide resolved
# clean up for the next repo
git checkout -- .
fi
done
if [ ! -z "$errors" ]; then
Expand Down