-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (157 loc) · 8.84 KB
/
test.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Test command workflow
on:
repository_dispatch:
types: [test-command]
jobs:
test:
name: Deploy values to test
runs-on: ubuntu-latest
env:
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
steps:
- name: Free root space
uses: almahmoud/free-root-space@main
with:
verbose: true
- uses: actions/checkout@v3
- name: Set defaults for all inputs
id: defs
run: |
SRCURL=${{ github.event.client_payload.slash_command.args.named.source || '' }}
if [ -z "$SRCURL" ]; then
SRCURL="https://github.com/${{github.repository}}/issues/$ISSUE_NUM"
SRCDIR=""
else
SRCDIR=$(basename $SRCURL)
fi
echo source=$SRCURL >> $GITHUB_OUTPUT
IDINPUT=${{ github.event.client_payload.slash_command.args.named.id || 'error' }}
echo id=$IDINPUT >> $GITHUB_OUTPUT
echo title=${{ github.event.client_payload.slash_command.args.named.title || 'No title' }} >> $GITHUB_OUTPUT
echo description=${{ github.event.client_payload.slash_command.args.named.description || '' }} >> $GITHUB_OUTPUT
echo section=${{ github.event.client_payload.slash_command.args.named.section || 'Others' }} >> $GITHUB_OUTPUT
echo docker=${{ github.event.client_payload.slash_command.args.named.docker || '' }} >> $GITHUB_OUTPUT
echo port=${{ github.event.client_payload.slash_command.args.named.port || '8787' }} >> $GITHUB_OUTPUT
echo precommand="${{ github.event.client_payload.slash_command.args.named.precommand || '' }}" >> $GITHUB_OUTPUT
echo fileskeep="${{ github.event.client_payload.slash_command.args.named.keepsource || 'TRUE' }}" >> $GITHUB_OUTPUT
STARTFILE=${{ github.event.client_payload.slash_command.args.named.startfile || '' }}
echo startfile=$STARTFILE >> $GITHUB_OUTPUT
CMDSTRING=${{ github.event.client_payload.slash_command.args.named.command }}
if [ -z $CMDSTRING ]; then
ORIGCMD='echo "{ \"visual_markdown_editing_is_default\": true }" > /etc/rstudio/rstudio-prefs.json && echo "setwd(\"/home/rstudio\"); setHook(\"rstudio.sessionInit\", function(newSession) { if (newSession) rstudioapi::filesPaneNavigate(getwd()) }, action = \"append\")" > /home/rstudio/.Rprofile; /init';
CMDSTRING="$ORIGCMD"
if [ ! -z $STARTFILE ]; then
STARTPATH=$STARTFILE
if [ ! -z $SRCDIR ]; then
STARTPATH="$SRCDIR/$STARTFILE"
fi
APPENDCMD='export TEMP=/tmp TMP=/tmp TMPDIR=/tmp TEMPDIR=/tmp; if [ -f \\"/home/rstudio/PLACEHOLDERSTARTPATH\\" ]; then echo \\"/home/rstudio/PLACEHOLDERSTARTPATH\\" > /tmp/startfile; else echo \\"/home/rstudio/PLACEHOLDERSTARTFILE\\" > /tmp/startfile; fi'
APPENDSTART=$(echo "$APPENDCMD" | sed "s@PLACEHOLDERSTARTPATH@$STARTPATH@g" | sed "s@PLACEHOLDERSTARTFILE@$STARTFILE@g")
CMDSTRING=$(echo "$APPENDSTART ; $ORIGCMD" | sed 's#(getwd())#(\\"\\\\$(dirname \\\\$(cat /tmp/startfile))\\"); rstudioapi::navigateToFile(\\"\\\\$(cat /tmp/startfile)\\")#g')
fi
fi
echo command=$CMDSTRING >> $GITHUB_OUTPUT
echo pkglist=${{ github.event.client_payload.slash_command.args.named.pkglist || '' }} >> $GITHUB_OUTPUT
echo vignettes=${{ github.event.client_payload.slash_command.args.named.vignettes || '' }} >> $GITHUB_OUTPUT
rm -f generated/${IDINPUT}.*
- name: Install Helm
run: curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: save kubeconfig
shell: bash
run: mkdir -p ~/.kube && echo "${{ secrets.TEST_KUBECONFIG }}" > ~/.kube/config
- name: Install Kubectl
run: curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl && kubectl version
- name: Get Current Job Log URL
uses: Tiryoh/gha-jobid-action@v0
id: jobs
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
job_name: "Deploy values to test"
per_page: 100
- name: Deploy
id: request
run: |
ID='${{steps.defs.outputs.id}}'
bash .github/scripts/request.sh -i "$ID" -t '${{steps.defs.outputs.title}}' -d '${{steps.defs.outputs.description}}' -s '${{steps.defs.outputs.section}}' -u '${{steps.defs.outputs.source}}' -c '${{steps.defs.outputs.docker}}' -p '${{steps.defs.outputs.port}}' -m '${{steps.defs.outputs.command}}' -k '${{steps.defs.outputs.pkglist}}' -v '${{steps.defs.outputs.vignettes}}' -b '${{steps.defs.outputs.startfile}}' -e "${{steps.defs.outputs.precommand}}" -f "${{steps.defs.outputs.fileskeep}}"
continue-on-error: true
- name: Create comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.PAT }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
_AUTO-GENERATED RESPONSE_
[Action Log](${{ steps.jobs.outputs.html_url }})
Your request has passed initial checks and is being built and/or deployed to the test instance.
Please wait further updates.
if: steps.request.outcome=='success'
- name: Create comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.PAT }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
_AUTO-GENERATED RESPONSE_
[Action Log](${{ steps.jobs.outputs.html_url }})
Your request has failed preliminary checks. Please make sure a corresponding `/request` command passes.
if: steps.request.outcome=='failure'
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: docker.io
username: almahmoud
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Deploy
id: deploy
run: |
ID='${{steps.defs.outputs.id}}'
bash .github/scripts/build.sh '${{steps.defs.outputs.id}}'
# Redo request with container in case it was just built
bash .github/scripts/request.sh -i "$ID" -t '${{steps.defs.outputs.title}}' -d '${{steps.defs.outputs.description}}' -s '${{steps.defs.outputs.section}}' -u '${{steps.defs.outputs.source}}' -c "$(cat generated/$ID.container)" -p '${{steps.defs.outputs.port}}' -m '${{steps.defs.outputs.command}}'
bash .github/scripts/deploy.sh -i "$ID" -s '${{steps.defs.outputs.section}}'
continue-on-error: true
- name: Create comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.PAT }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
_AUTO-GENERATED RESPONSE_
[Action Log](${{ steps.jobs.outputs.html_url }})
Your workshop has been successfully deployed to the [test instance](https://workshop.bioconductor.org). :sparkles:
Please test your workshop on the development instance and notify us via comment when you deem it ready for public consumption on the production instance.
if: steps.request.outcome=='success' && steps.deploy.outcome=='success'
- name: Create comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.PAT }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
_AUTO-GENERATED RESPONSE_
[Action Log](${{ steps.jobs.outputs.html_url }})
Your request has been received but is currently failing its deployment on test.
If the corresponding `/request` command has passed with the same parameters, this is likely a bug.
if: steps.request.outcome=='failure' || steps.deploy.outcome=='failure'
- run: "cp -r generated /tmp"
- name: Push generated
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 50
shell: bash
command: |
set -x
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git pull origin main || git reset --hard origin/main
git config user.name github-actions
git config user.email [email protected]
cp -r /tmp/generated ./
git add ./generated
git commit -m "Push generated ${{steps.defs.outputs.id}}"
git push