-
Notifications
You must be signed in to change notification settings - Fork 6
133 lines (117 loc) · 4.81 KB
/
tools-iuc.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# 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