repo-file-sync-action icon indicating copy to clipboard operation
repo-file-sync-action copied to clipboard

Include `repo` object when templating

Open kenodegard opened this issue 1 year ago • 1 comments

This change adds the repo object to every Nunjucks context for easier bulk templating.

The way templating is currently defined makes it very verbose to template several repos, especially when trying to do relatively simple templating like injecting the repo name. We'd effectively need:

# sync.yml

user/repo1:
  - source: src/README.md
    template:
      user: user
      repo: repo1

user/repo2:
  - source: src/README.md
    template:
      user: user
      repo: repo2

...
# README.md

Hello from {{ repo }} by {{ user }}!

By pre-populating the context with the repo object we are able to simplify it and do the following instead:

# sync.yml

group:
  - repos: |
      user/repo1
      user/repo2
      ...
    files:
      - source: src/README.md
        template: true
# README.md

Hello from {{ repo.name }} by {{ repo.user }}!

kenodegard avatar Apr 26 '23 04:04 kenodegard

@BetaHuhn will you have time to review this soon?

kenodegard avatar May 05 '23 03:05 kenodegard