Skip to content

iwc

iwc #67

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: iwc
# Controls when the action will run.
on:
schedule:
- cron: "0 7 17 * *"
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
- name: Checkout autoupdate
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
repository: planemo-autoupdate/autoupdate
ref: main
path: autoupdate
- name: Checkout IWC
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
repository: planemo-autoupdate/iwc
ref: main
path: iwc
- 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 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 iwc
echo "Adding upstream..."
git remote add upstream https://github.com/galaxyproject/iwc.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 workflows/)
echo $REPOS
for REPO in $REPOS; do
# first check if it's in the skip list
# if [[ ! `cat $BASEDIR/autoupdate/iwc_skip_list` =~ $REPO ]]
if [[ 1 ]]
then
# git checkout upstream/main
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/iwc_skip_list > $BASEDIR/autoupdate.log
rm -f tool_test_output.* tools.yml
cd $BASEDIR/iwc
if [[ $(git diff) ]]
then
OLD_TITLE=$(gh pr list --limit 10000 | grep planemo-autoupdate:$REPO.\s*OPEN | cut -f 2)
if [[ $OLD_TITLE ]] # just need to update PR title
then
PR_EXISTS=1
else
PR_EXISTS=0
fi
TITLE=$(python3 $BASEDIR/autoupdate/pr_text_iwc.py --repo $REPO --log $BASEDIR/autoupdate.log --out $BASEDIR/body.txt --changelog $REPO/CHANGELOG.md --pr-exists $PR_EXISTS)
echo "Adding..."
git add .
echo "Committing..."
git commit -m "$TITLE"
echo "Push branch to remote..."
git push --set-upstream origin $REPO
if [[ $PR_EXISTS -eq 1 ]] # 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 10000 | 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/iwc --body-file $BASEDIR/body.txt
fi
fi
else
echo "Skipping $REPO..."
fi
done