Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for passing a list #11

Closed
nobe4 opened this issue May 2, 2023 · 0 comments · Fixed by #13
Closed

Add example for passing a list #11

nobe4 opened this issue May 2, 2023 · 0 comments · Fixed by #13
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@nobe4
Copy link

nobe4 commented May 2, 2023

Hi 👋

I found out today how to pass a list of arguments via the variables. I struggled a bit and this solution could be beneficial for others, in case you want to add it to the readme/docs.

Here's the setup:

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - id: run
        run:  echo "files=a,b,c" >> "$GITHUB_OUTPUT"

      - uses: GrantBirki/comment
        with:
          # other config
          vars: |
            files: ${{ steps.run.outputs.files }}
          body: |
            # Files
            {% for file in files.split(",") %}
            - `{{ file }}`
            {% else %}
            - No file
            {% endfor %}

What's important here is to serialize the files list when passing between steps. Passing a multiline-string breaks the vars value.

Thanks ✨

@GrantBirki GrantBirki self-assigned this May 2, 2023
@GrantBirki GrantBirki added the documentation Improvements or additions to documentation label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants