name: nf-core AWS full size tests
# This workflow is triggered on push to the master branch.
# It runs the -profile 'test_full' on AWS batch

on:
  release:
    types: [published]

jobs:
  run-awstest:
    name: Run AWS full tests
    if: github.repository == 'nf-core/hlatyping'
    runs-on: ubuntu-latest
    steps:
      - name: Setup Miniconda
        uses: goanpeca/setup-miniconda@v1.0.2
        with:
          auto-update-conda: true
          python-version: 3.7
      - name: Install awscli
        run: conda install -c conda-forge awscli
      - name: Start AWS batch job
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          TOWER_ACCESS_TOKEN: ${{ secrets.AWS_TOWER_TOKEN }}
          AWS_JOB_DEFINITION: ${{ secrets.AWS_JOB_DEFINITION }}
          AWS_JOB_QUEUE: ${{ secrets.AWS_JOB_QUEUE }}
          AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
        run: |
          aws batch submit-job \
            --region eu-west-1 \
            --job-name nf-core-hlatyping \
            --job-queue $AWS_JOB_QUEUE \
            --job-definition $AWS_JOB_DEFINITION \
            --container-overrides '{"command": ["nf-core/hlatyping", "-r '"${GITHUB_SHA}"' -profile test_full --outdir s3://'"${AWS_S3_BUCKET}"'/hlatyping/results-'"${GITHUB_SHA}"' -w s3://'"${AWS_S3_BUCKET}"'/hlatyping/work-'"${GITHUB_SHA}"' -with-tower"], "environment": [{"name": "TOWER_ACCESS_TOKEN", "value": "'"$TOWER_ACCESS_TOKEN"'"}]}'
