actions-includes icon indicating copy to clipboard operation
actions-includes copied to clipboard

Support for `includes-script` in custom places

Open drdanz opened this issue 4 years ago • 4 comments

It would be nice to be able to include scripts in custom places with custom tags.

For example, it would be nice if a script could be inserted using the command tag in when using the nick-invision/retry action

drdanz avatar Mar 12 '21 19:03 drdanz

Any idea on what could be a workable syntax?

mithro avatar Mar 15 '21 00:03 mithro

Perhaps something like this?

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  includes-script: [ "command", script.py ]

This should expand to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  shell: python
  command: |
    <script.py content>

drdanz avatar Mar 18 '21 11:03 drdanz

Option 1

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  includes-script:
    command: script.py

should expand to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  shell: python
  command: |
    <script.py content>

Then also;

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  includes-script: script.py

is equivalent to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  includes-script:
    runs: script.py

Option 2 -- outputs dictionary

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  includes-script:
    uses: script.py
    outputs:
      script: command
      shell: shell-type

should expand to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  shell-type: python
  command: |
    <script.py content>

Then also;

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  includes-script: script.py

is equivalent to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  includes-script:
    uses: script.py
    outputs:
      script: runs
      shell: shell

Option 3 -- includes-script under key

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  command:
    includes-script: script.py

should expand to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  shell-type: python
  command: |
    <script.py content>

Then also;

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  runs:
    includes-script: script.py

is equivalent to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  runs: |
    <script>

Option 4 - !include

Use same syntax as https://github.com/codeindulgence/yaml-includes and https://www.home-assistant.io/docs/configuration/splitting_configuration/ and https://pypi.org/project/pyyaml-include/

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  command: !include: script.py

should expand to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  shell-type: python
  command: |
    <script.py content>

Then also;

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  runs: !include: script.py

is equivalent to

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  runs: |
    <script>
GitHub
Adds support for the YAML include directive as defined by the [RAML spec]. - codeindulgence/yaml-includes
Home Assistant
Splitting the configuration.yaml into several files.
PyPI
Extending PyYAML with a custom constructor for including YAML files within YAML files

mithro avatar Mar 18 '21 15:03 mithro

Another action that might benefit from this: https://github.com/marketplace/actions/github-script

GitHub
Run simple scripts using the GitHub client

drdanz avatar Mar 26 '21 10:03 drdanz