-
Notifications
You must be signed in to change notification settings - Fork 3
98 lines (89 loc) · 2.78 KB
/
live-preview.yaml
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
name: Preview PR on galaxy.odahub.fr
on:
pull_request:
branches:
- main
types:
- opened
- labeled
- synchronize
- unlabeled
- closed
paths-ignore:
- '.github/**'
- 'deprecated/**'
- 'docs/**'
- '*'
env:
GALAXY_FORK: galaxyproject
GALAXY_BRANCH: release_23.1
jobs:
setup:
if: contains( github.event.pull_request.labels.*.name, 'test-live') && github.event.action != 'closed'
name: Determine changed repositories
runs-on: ubuntu-latest
outputs:
tool-list: ${{ steps.discover.outputs.tool-list }}
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fake a Planemo run to determine tool list
uses: galaxyproject/planemo-ci-action@v1
id: discover
with:
galaxy-fork: ${{ env.GALAXY_FORK }}
galaxy-branch: ${{ env.GALAXY_BRANCH }}
python-version: "3.7"
- name: Show tool list
run: echo '${{ steps.discover.outputs.tool-list }}'
# deploy the tools
deploy:
name: Deploy
if: contains( github.event.pull_request.labels.*.name, 'test-live') && needs.setup.outputs.tool-list
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install requirenments
run: sudo apt-get install -y ansible
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy tools
env:
TOOL_LIST: ${{ needs.setup.outputs.tool-list }}
pr_num: ${{ github.event.pull_request.number }}
run: |
cd deploy-preview
dir_list=`for tl in $TOOL_LIST ; do echo $tl | awk -F '/' '{for(i=2;i<=(NF-1);i++) printf("%s%s",$i,i==(NF-1)?" ":FS)}'; done | uniq`
for dr in $dir_list; do
tools_list=`for tl in $TOOL_LIST; do if [[ "$tl" == *"$dr"* ]] ; then basename $tl ; fi ; done`
export tools_list
export tool_dir=$dr
ansible-playbook deploy.yml
done
uninstall:
name: Uninstall
if: contains( github.event.pull_request.labels.*.name, 'test-live') == false || github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install requirenments
run: sudo apt-get install -y ansible
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Uninstall tools
env:
pr_num: ${{ github.event.pull_request.number }}
run: |
cd deploy-preview
ansible-playbook remove.yml