Skip to content

tools-iuc

tools-iuc #196

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: tools-iuc
# Controls when the action will run.
on:
schedule:
- cron: "0 4 * * 1"
push:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# used for the skip lists
- name: Checkout autoupdate
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
repository: planemo-autoupdate/autoupdate
ref: main
path: autoupdate
- name: Checkout tools-iuc
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
repository: planemo-autoupdate/tools-iuc
ref: main
path: tools-iuc
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Cache downloads
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: cache-${{ matrix.python-version }}
# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo "Installing planemo..."
pip3 install https://github.com/galaxyproject/planemo/archive/refs/heads/master.zip
# git credentials
git config --global user.email "[email protected]"
git config --global user.name "planemo-autoupdate"
echo ${{ secrets.PAT }} > token.txt
gh auth login --with-token < token.txt
BASEDIR=`pwd`
ls $BASEDIR/*
cd tools-iuc
echo "Adding upstream..."
git remote add upstream https://github.com/galaxyproject/tools-iuc.git
echo "Getting git remote..."
git remote -v
echo "Pulling latest from upstream..."
git fetch --all
git pull upstream main
git push origin main
REPOS=$(planemo ci_find_repos tools/)
echo $REPOS
for REPO in $REPOS; do
echo $REPO
# checkout branch, create if it doesn't exist
if [[ $(gh pr list --limit 10000 | grep planemo-autoupdate:$REPO.\s*OPEN) ]]
then
echo "PR exists, we will checkout the branch and add to it"
git checkout --track origin/$REPO
else
if [[ $(git branch -a --list origin/$REPO) ]]
then
echo "Branch exists without an open PR - deleting"
git push origin --delete $REPO
fi
echo "Creating branch and checking out"
git checkout -b $REPO upstream/main
fi
git branch
echo "Running autoupdate command..."
cd $REPO
planemo autoupdate . --skiplist $BASEDIR/autoupdate/tools-iuc_skip_list > $BASEDIR/autoupdate.log
rm -f tool_test_output.*
cd $BASEDIR/tools-iuc
if [[ $(git diff) ]]
then
TITLE=$(python3 $BASEDIR/autoupdate/pr_text.py --repo $REPO --log $BASEDIR/autoupdate.log --shed $REPO/.shed.yml --out $BASEDIR/body.txt)
# first check if a closed PR exists with the same title - if so, we don't continue
if [[ ! $(gh pr list -s closed --limit 1000 -A planemo-autoupdate | grep "$TITLE" | grep CLOSED) ]]
then
echo "Adding..."
git add .
echo "Committing..."
git commit -m "$TITLE"
echo "Push branch to remote..."
git push --set-upstream origin $REPO
OLD_TITLE=$(gh pr list --limit 1000 -A planemo-autoupdate | grep planemo-autoupdate:$REPO | cut -f 2)
if [[ $OLD_TITLE ]] # just need to update PR title
then
if [[ $OLD_TITLE == *\) ]] # older PRs
then
NEW_TITLE=$(echo $OLD_TITLE | cut --complement -f 4 -d ' ' && echo " to " && echo $TITLE | cut -f 7 -d ' ')
else # newer PRs
NEW_TITLE=$(echo $OLD_TITLE | cut --complement -f 7 -d ' ' && echo $TITLE | cut -f 7 -d ' ')
fi
PR_NUMBER=$(gh pr list --limit 1000 -A planemo-autoupdate | grep planemo-autoupdate:$REPO | cut -f 1)
gh pr edit $PR_NUMBER -t "$NEW_TITLE"
else # we need to create a PR
echo "Creating a PR..."
gh pr create --base main --head planemo-autoupdate:$REPO --title "$TITLE" --repo galaxyproject/tools-iuc --body-file $BASEDIR/body.txt
fi
fi
fi
# clean up for the next tool
git checkout -- $REPO
done