test-command #246
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 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 |