diff --git a/.github/workflows/cloudos-ci.yml b/.github/workflows/cloudos-ci.yml index e2242a5..7f2bdf0 100644 --- a/.github/workflows/cloudos-ci.yml +++ b/.github/workflows/cloudos-ci.yml @@ -3,11 +3,11 @@ on: [push] jobs: custom_test: runs-on: ubuntu-latest - name: Local test with act + name: Dry run test for cloudos job run steps: - name: Checkout uses: actions/checkout@v2 - - name: Echo cloudos command + - name: Print cloudos job run command (dry_run set to true) uses: ./ # Uses an action in the root directory id: cloudos_job_run with: @@ -17,4 +17,5 @@ jobs: project_name: 'cloudos-cli-tests' workflow_name: 'cgpu/rnatoy' nextflow_profile: 'test' - cloudos_cli_flags: '--resumable --spot' \ No newline at end of file + cloudos_cli_flags: '--resumable --spot' + dry_run: 'true' \ No newline at end of file diff --git a/README.md b/README.md index 5deb8a2..4cd9888 100644 --- a/README.md +++ b/README.md @@ -1 +1,121 @@ -# action-custom-action \ No newline at end of file +# GitHub Action: Run Lifebit CloudOS jobs with cloudos-cli + +This github action uses the [`cloudos-cli`](https://github.com/lifebit-ai/cloudos-cli), the official Lifebit CloudOS API client, to launch jobs programmatically using the `cloudos job run` command. + +## Example usage + +```yaml +on: [push] + +jobs: + cloudos_job_run: + runs-on: ubuntu-latest + name: Submit CloudOS job programmatically + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Echo cloudos command + uses: lifebit-ai/action-cloudos-cli@v0.1.0 + id: cloudos_job_run + with: + apikey: ${{ secrets.CLOUDOS_APIKEY }} + cloudos_url: 'https://cloudos.lifebit.ai' + workspace_id: ${{ secrets.CLOUDOS_WORKSPACE_ID }} + project_name: 'cloudos-cli-tests' + workflow_name: 'cgpu/rnatoy' + nextflow_profile: 'test' + cloudos_cli_flags: '--resumable --spot' +``` + + +## Inputs + +### `dry_run` + +If set to `'true'` the action only prints the `cloudos job run` command instead of executing it. Secrets are stripped before printing. This mode can be used for testing. + +### `apikey` + +The Lifebit CloudOS user personal API token. + +> :warning: It is highly recommended to use Github Actions Secrets to define this secret variable. Follow the [official Github Actions documentation for reporsitory secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) to set this up for your reporsitory. + + +### `cloudos_url` + +The Lifebit CloudOS application hostname without a trailing backslash eg https://cloudos.lifebit.ai + +### `workspace_id` + +The Lifebit CloudOS workspace id. It Can be found under Settings in the web application. It is recommended to use Github Action repository secrets to set up this variable. + +### `project_name` + +The Lifebit CloudOS workspace id. It can be created and selected from the Lifebit CloudOS web application user interface under Projects. + +### `workflow_name` + +The Lifebit CloudOS workflow name. It can be created and selected from the Lifebit CloudOS web application user interface under Pipelines & Tools. + + +### `job_config` + +A local file with suffix .config, that includes only a params scope enclosed in curly brackets. The file should contain parameter key:value pairs. For example see: [cloudos/examples/rnatoy.config'](https://github.com/lifebit-ai/cloudos-cli/blob/dev/cloudos/examples/rnatoy.config') + + +### `nextflow_profile` + +One or many comma separated strings, indicating the nextflow profile/s to use with your job. Only applicable to Nextflow workflows.' + +### `git_commit` + +The exact whole 40 character commit hash to run for the selected pipeline. If not specified it defaults to the last commit of the default branch. + +### `git_tag` + +The version tag of the chosen workflow repository. It must exist in the repository + + +### `job_name` + +A name to assign to the job run. + +### `instance_type` + +The type of AWS EC2 instance to use as master node for the job eg c5.xlarge + +### `instance_disk` + +Disk storage in GB to be used for the master node vm. + + +### `storage_mode` + +The storage mode to use. Available options: [regular,lustre]. Regular is EBS. + +### `lustre_size` + +The lustre storage to be used when --storage-mode=lustre, in GB. It should be 1200 or a multiple of it.' + +### `wait_time` + +Max time to wait (in seconds) to job completion + +### `wdl_mainfile` + +For WDL workflows, which mainFile (.wdl) is configured to use (string). This is defined when the WDL repository is imported under Pipelines & Tools using the Lifebit CloudOS web application user interface. + +### `wdl_importsfile` + +For WDL workflows, which importsFile (.zip) is configured to use (string). This is defined when the WDL repository is imported under Pipelines & Tools using the Lifebit CloudOS web application user interface. + +### `cromwell_token` + +Specific Cromwell server authentication token. Only required for WDL jobs. + +### `repository_platform` + +Name of the repository platform of the workflow. Default=github. +### `cloudos_cli_flag` + +Additional cloudos-cli flags, space separated eg `'--spot --resumable'`. Available options: `[--spot, --batch, --resumable, --verbose, --wait-completion]` diff --git a/action.yaml b/action.yaml index 6ada354..6eb0f48 100644 --- a/action.yaml +++ b/action.yaml @@ -26,7 +26,6 @@ inputs: nextflow_profile: description: 'One or many comma separated strings, indicating the nextflow profile/s to use with your job. Only applicable to Nextflow workflows.' required: false - default: 'standard' git_commit: description: 'The exact whole 40 character commit hash to run for the selected pipeline. If not specified it defaults to the last commit of the default branch.' required: false @@ -40,23 +39,18 @@ inputs: instance_type: description: 'The type of AWS EC2 instance to use as master node for the job eg c5.xlarge' required: false - default: 'c5.xlarge' instance_disk: description: 'Disk storage in GB to be used for the master node vm.' required: false - default: '500' storage_mode: description: 'The storage mode to use. Available options: [regular,lustre]. Regular is EBS.' required: false - default: 'regular' lustre_size: description: 'The lustre storage to be used when --storage-mode=lustre, in GB. It should be 1200 or a multiple of it.' required: false - default: '1200' wait_time: description: 'Max time to wait (in seconds) to job completion' required: false - default: '3600' wdl_mainfile: description: 'For WDL workflows, which mainFile (.wdl) is configured to use (string). This is defined when the WDL repository is imported under Pipelines & Tools using the Lifebit CloudOS web application user interface.' required: false @@ -73,6 +67,10 @@ inputs: description: 'Additional cloudos-cli flags, space separated eg "--spot --resumable". Available options: [--spot, --batch, --resumable, --verbose, --wait-completion]' required: false default: '' + dry_run: + description: 'Mode of execution for the action, by default the API call will be sent. Set to dry_run: true if you only want to print the command (strips secrets before printing).' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' @@ -96,4 +94,5 @@ runs: - ${{ inputs.wdl_importsfile }} - ${{ inputs.cromwell_token }} - ${{ inputs.repository_platform }} - - ${{ inputs.cloudos_cli_flags}} \ No newline at end of file + - ${{ inputs.cloudos_cli_flags}} + - ${{ inputs.dry_run}} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index e316823..6757939 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,5 +25,5 @@ if [[ ${INPUT_CROMWELL_TOKEN} ]]; then CLOUDOS_RUN_CMD+=" --cromwell-token if [[ ${INPUT_REPOSITORY_PLATFORM} ]]; then CLOUDOS_RUN_CMD+=" --repository-platform ${INPUT_REPOSITORY_PLATFORM}" ; fi if [[ ${INPUT_CLOUDOS_CLI_FLAGS} ]]; then CLOUDOS_RUN_CMD+=" ${INPUT_CLOUDOS_CLI_FLAGS}" ; fi -$CLOUDOS_RUN_CMD +if [[ ${INPUT_DRY_RUN} != 'true' ]]; then $CLOUDOS_RUN_CMD ; fi printf '%s\n' "${CLOUDOS_RUN_CMD//$INPUT_APIKEY/}" \ No newline at end of file