Skip to content

Commit

Permalink
Merge pull request #36 from lldelisle/improve_autoupdate
Browse files Browse the repository at this point in the history
Improve autoupdate
  • Loading branch information
lldelisle authored Sep 23, 2024
2 parents 58f2479 + d09bb8d commit 5b27d3b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
errors=""
REPOS=$(planemo ci_find_repos "${{ matrix.upstream_repo_dir }}")
for REPO in $REPOS; do
echo $REPO
# First try to update
echo "Running autoupdate command..."
cd "$REPO"
planemo autoupdate . --skiplist "${{ github.workspace }}/autoupdate/${{ matrix.upstream_repo_owner }}_${{ matrix.upstream_repo_name }}_skip_list" > "${{ github.workspace }}/autoupdate.log"
# This may fail
planemo autoupdate . --skiplist "${{ github.workspace }}/autoupdate/${{ matrix.upstream_repo_owner }}_${{ matrix.upstream_repo_name }}_skip_list" > "${{ github.workspace }}/autoupdate.log" || errors="${errors}\nCannot autoupdate $REPO"
rm -f tool_test_output.* tools.yml
cd -
# Check if it changed something
Expand Down Expand Up @@ -150,8 +152,8 @@ jobs:
if ! git diff $DIFF_BRANCH --quiet $FILE_TO_CHECK; then
echo "There are changes"
if [ "$PR_EXISTS" -eq 1 ]; then
# Check if there was manual commits
LAST_AUTHOR=$(git log -1 --pretty=format:'%an')
# Check if the last commit of the existing branch was manual
LAST_AUTHOR=$(git log -1 --pretty=format:'%an' $DIFF_BRANCH)
if [ "$LAST_AUTHOR" != "planemo-autoupdate" ]; then
# There were manual commits we do not do anything
gh pr comment "$PR_NUMBER" --body "There are new updates, if you want to integrate them, close the PR and delete branch."
Expand Down Expand Up @@ -179,15 +181,27 @@ jobs:
else # newer PRs
NEW_TITLE="$(echo "$OLD_TITLE" | cut --complement -f 7 -d ' ') $(echo "$TITLE" | cut -f 7 -d ' ')"
fi
gh pr edit "$PR_NUMBER" -t "$NEW_TITLE"
if [ "$NEW_TITLE" != "$OLD_TITLE" ]; then
# This may fail if for example the PR was opened by someone else like
# https://github.com/bgruening/galaxytools/pull/1353
gh pr edit "$PR_NUMBER" -t "$NEW_TITLE" || errors="${errors}\nCannot change title of PR $PR_NUMBER for $REPO"
fi
# If the PR is closed, we need to reopen it.
if [ "$PR_STATUS" = "CLOSED" ]; then
gh pr reopen "$PR_NUMBER"
# This may fail
gh pr reopen "$PR_NUMBER" || errors="${errors}\nCannot reopen PR $PR_NUMBER for $REPO"
fi
# Comment on the PR
gh pr comment "$PR_NUMBER" --body "There are new updates, they have been integrated to the PR, check the file diff."
else # we need to create a PR
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
fi
done
if [ ! -z "$errors" ]; then
echo "ERRORS OCCURED DURING AUTOUPDATE:"
echo -e $errors
exit 1
fi
working-directory: ./tools_repo

0 comments on commit 5b27d3b

Please sign in to comment.