diff --git a/.github/workflows/CODEOWNERS b/.github/workflows/CODEOWNERS new file mode 100644 index 0000000..227fdf4 --- /dev/null +++ b/.github/workflows/CODEOWNERS @@ -0,0 +1,3 @@ +# require 1 PR approval from delivery-admins if the files changed are within the .github folder +* @cgpu + diff --git a/.github/workflows/cloudos-ci.yml b/.github/workflows/cloudos-ci.yml index ec4f542..c41c21c 100644 --- a/.github/workflows/cloudos-ci.yml +++ b/.github/workflows/cloudos-ci.yml @@ -8,7 +8,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Print cloudos job run command (dry_run set to true) - uses: lifebit-ai/action-cloudos-cli@0.2.0 + uses: lifebit-ai/action-cloudos-cli@0.3.0 id: cloudos_job_run with: apikey: ${{ secrets.CLOUDOS_APIKEY }} @@ -24,5 +24,7 @@ jobs: instance_disk: 40 wait_time: 7200 cost_limit: 0.1 + - name: Get the cloudos_job_run job ID + run: echo ${{steps.cloudos_job_run.outputs.job_id}} diff --git a/README.md b/README.md index a820827..eb858ee 100644 --- a/README.md +++ b/README.md @@ -128,3 +128,8 @@ Request interval in seconds. The options is influencing the request interval for Additional cloudos-cli flags, space separated eg `'--spot --resumable'`. Available options: `[--spot, --batch, --resumable, --verbose, --wait-completion]` +## Outputs + +### `job_id` + +Job ID extracted from Lifebit CloudOS cloudos-cli. \ No newline at end of file diff --git a/action.yaml b/action.yaml index 6cfe7d4..bbba45d 100644 --- a/action.yaml +++ b/action.yaml @@ -77,6 +77,9 @@ inputs: 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: false +outputs: + job_id: + description: 'Job ID from Lifebit CloudOS cloudos-cli' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 75c112a..7be488c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,5 +27,14 @@ if [[ ${INPUT_REQUEST_INTERVAL} ]]; then CLOUDOS_RUN_CMD+=" --request-interva if [[ ${INPUT_COST_LIMIT} ]]; then CLOUDOS_RUN_CMD+=" --cost-limit ${INPUT_COST_LIMIT}" ; fi if [[ ${INPUT_CLOUDOS_CLI_FLAGS} ]]; then CLOUDOS_RUN_CMD+=" ${INPUT_CLOUDOS_CLI_FLAGS}" ; fi -if [[ ${INPUT_DRY_RUN} != 'true' ]]; then $CLOUDOS_RUN_CMD ; fi -printf '%s\n' "${CLOUDOS_RUN_CMD//$INPUT_APIKEY/}" +if [[ ${INPUT_DRY_RUN} != 'true' ]] +then + stdout=$($CLOUDOS_RUN_CMD) + echo $stdout + + job_idWithSpace=$(awk -F"Your assigned job id is: |Please, wait until job completion or max wait time of 3600 seconds is reached." '{print $2}' <<< "$stdout") + job_id=$(echo $job_idWithSpace | tr -d '\r' | tr -d '\n') +else + job_id="" +fi +echo "::set-output name=job_id::$job_id"