diff --git a/Readme.md b/Readme.md index 61223c75..a31aba81 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,8 @@ It is a cause of failed jobs. For this case, the action `wretry.action` can retr - Default action always includes both `pre` and `post` stages. If an external action contains a `pre` and/or `post` stage, the action will also execute these stages. - The repository includes subdirectories with alternative action setups that can skip the `pre` or/and `post` stages, as necessary. - Action handles conditions in `JavaScript` and `Docker` actions ( fields `pre-if` and `post-if` ). Some conditions can be unsolvable and then action skips the stage. -- Resolves external action default inputs from next contexts : `github`, `env`, `job`, `matrix`, `inputs`. +- Resolves external action default inputs from next contexts : `github`, `env`, `job`, `matrix`, `steps`, `inputs`. +- Can resolve user-provided context `steps`. - Retries actions with defined number of attempts ( default is 2 ). - Retries actions with defined delay between attempts ( default is 0 ). @@ -89,6 +90,10 @@ Pass context `env` into an external action. Action cannot resolve separate envir Pass context `github` into an external action. Default is global context `github`. +### `inputs_context` + +Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolves all inputs from passed options and action description. To pass correct inputs context you need to combine passed options into and stringified JSON object. + ### `job_context` Pass context `job` into an external action. Default is context `job` of a job. @@ -97,6 +102,10 @@ Pass context `job` into an external action. Default is context `job` of a job. Pass context `matrix` into an external action. Default is context `matrix` of a job. +### `steps_context` + +Pass context `steps` into an external action. If you need valid context `steps`, then add option `steps_context : ${{ toJSON( steps ) }}`. + ### `attempt_limit` Set number of attempts. Default is 2. diff --git a/action.yml b/action.yml index d11e8b47..23f41dbb 100644 --- a/action.yml +++ b/action.yml @@ -27,6 +27,10 @@ inputs: description: 'Pass context `github` into an external action. Default is global context `github`.' required: false default: ${{ toJSON( github ) }} + inputs_context: + description: 'Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolves all inputs from passed options and action description.' + required: false + default: '{}' job_context: description: 'Pass context `job` into an external action. Default is context `job` of a job.' required: false @@ -35,8 +39,8 @@ inputs: description: 'Pass context `matrix` into an external action. Default is context `matrix` of a job.' required: false default: ${{ toJSON( matrix ) }} - inputs_context: - description: 'Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolve all inputs. If you need valid context `inputs`, then add option as described in `Readme.md`.' + steps_context: + description: 'Pass context `steps` into an external action. If you need valid context `steps`, then add option as described in `Readme.md`.' required: false default: '{}' attempt_limit: diff --git a/main/action.yml b/main/action.yml index afd8d488..8e53d873 100644 --- a/main/action.yml +++ b/main/action.yml @@ -27,6 +27,10 @@ inputs: description: 'Pass context `github` into an external action. Default is global context `github`.' required: false default: ${{ toJSON( github ) }} + inputs_context: + description: 'Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolves all inputs from passed options and action description.' + required: false + default: '{}' job_context: description: 'Pass context `job` into an external action. Default is context `job` of a job.' required: false @@ -35,8 +39,8 @@ inputs: description: 'Pass context `matrix` into an external action. Default is context `matrix` of a job.' required: false default: ${{ toJSON( matrix ) }} - inputs_context: - description: 'Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolve all inputs. If you need valid context `inputs`, then add option as described in `Readme.md`.' + steps_context: + description: 'Pass context `steps` into an external action. If you need valid context `steps`, then add option as described in `Readme.md`.' required: false default: '{}' attempt_limit: diff --git a/post/action.yml b/post/action.yml index 51d4381e..743447d0 100644 --- a/post/action.yml +++ b/post/action.yml @@ -27,6 +27,10 @@ inputs: description: 'Pass context `github` into an external action. Default is global context `github`.' required: false default: ${{ toJSON( github ) }} + inputs_context: + description: 'Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolves all inputs from passed options and action description.' + required: false + default: '{}' job_context: description: 'Pass context `job` into an external action. Default is context `job` of a job.' required: false @@ -35,8 +39,8 @@ inputs: description: 'Pass context `matrix` into an external action. Default is context `matrix` of a job.' required: false default: ${{ toJSON( matrix ) }} - inputs_context: - description: 'Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolve all inputs. If you need valid context `inputs`, then add option as described in `Readme.md`.' + steps_context: + description: 'Pass context `steps` into an external action. If you need valid context `steps`, then add option as described in `Readme.md`.' required: false default: '{}' attempt_limit: diff --git a/pre/action.yml b/pre/action.yml index 599335bc..3a55ed3e 100644 --- a/pre/action.yml +++ b/pre/action.yml @@ -27,6 +27,10 @@ inputs: description: 'Pass context `github` into an external action. Default is global context `github`.' required: false default: ${{ toJSON( github ) }} + inputs_context: + description: 'Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolves all inputs from passed options and action description.' + required: false + default: '{}' job_context: description: 'Pass context `job` into an external action. Default is context `job` of a job.' required: false @@ -35,8 +39,8 @@ inputs: description: 'Pass context `matrix` into an external action. Default is context `matrix` of a job.' required: false default: ${{ toJSON( matrix ) }} - inputs_context: - description: 'Pass context `inputs` into an external action. The action cannot resolve context `inputs` and resolve all inputs. If you need valid context `inputs`, then add option as described in `Readme.md`.' + steps_context: + description: 'Pass context `steps` into an external action. If you need valid context `steps`, then add option as described in `Readme.md`.' required: false default: '{}' attempt_limit: diff --git a/src/Common.js b/src/Common.js index 4afaafb8..fcd032a1 100644 --- a/src/Common.js +++ b/src/Common.js @@ -170,20 +170,10 @@ function contextGet( contextName ) githubContext = githubContextUpdate( githubContext ); return githubContext; } - else if( contextName === 'job' ) + else if( [ 'job', 'matrix', 'inputs', 'steps' ].includes( contextName ) ) { - const jobContext = JSON.parse( core.getInput( 'job_context' ) ); - return jobContext; - } - else if( contextName === 'matrix' ) - { - const matrixContext = JSON.parse( core.getInput( 'matrix_context' ) ); - return matrixContext; - } - else if( contextName === 'inputs' ) - { - const inputsContext = JSON.parse( core.getInput( 'inputs_context' ) ); - return inputsContext; + const context = JSON.parse( core.getInput( `${ contextName }_context` ) ); + return context; } _.sure