需要让 Jinja2 模板在 Windows 的 GitHub Runner 上运行。

huangapple go评论75阅读模式
英文:

Need Jinja2 templates to work on Windows github runner

问题

I have the following file in my repo containing variables that should be evaluated after checkout.

cat infra/.env_qa

myname="Appone_${{ inputs.component }}"
port="8814"
server_list="{{ secrets.deploy_pass }}"
....

https://github.com/cuchi/jinja2-action

I use Jinja templates to generate a new file with the values as below:

- name: Setup env file
  uses: cuchi/jinja2-action@v1.2.0
  with:
    template: infra/.env_qa.j2
    output_file: infra/.env_qa

Unfortunately, this action runs only on Linux while I have a Windows runner.

I would like to know

  1. Alternate Jinja template action that runs on Windows
  2. How can I determine if an action is designed to run on Windows or not without running it.
英文:

I have the following file in my repo containing variables that should be evaluated after checkout.

cat infra/.env_qa

myname="Appone_${{ inputs.component }}"
port="8814"
server_list="{{ secrets.deploy_pass }}"
....

https://github.com/cuchi/jinja2-action

I use Jinja templates to generate a new file with the values as below:

- name: Setup env file
  uses: cuchi/jinja2-action@v1.2.0
  with:
    template: infra/.env_qa.j2
    output_file: infra/.env_qa

Unfortunately, this action runs only on Linux while I have a Windows runner.

I would like to know

  1. Alternate Jinja template action that runs on Windows
  2. How can I determine if an action is designed to run on Windows or not without running it.

答案1

得分: 1

  1. 可以在GitHub Actions Marketplace上搜索替代的 Jinja 模板操作。作为解决方法,您可以在单独的作业中在 ubuntu-latest 下运行该操作,将生成的文件上传为工件,然后在 Windows 作业下下载它。或者,您可以直接从命令行使用Jinja2

  2. 如何确定某个操作是否设计为在Windows上运行,而不运行它?基于Docker的操作仅在Linux上受支持。您可以从它们的 action.yml 文件中识别它们,并查找 runs 部分,例如这里

英文:

> 1. Alternate Jinja template action that runs on Windows?

You can search on the GitHub Actions Marketplace.

As a workaround, you can run that action under ubuntu-latest in a separate job, upload the generated file as an artifact, and then download it under your Windows job. Or, you can directly use Jinja2 from the command line.

> 2. How can I determine if an action is designed to run on Windows or not without running it?

Docker based actions are supported only on Linux. You can identify them from their action.yml file and look for runs section e.g. see here.

huangapple
  • 本文由 发表于 2023年5月10日 18:27:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76217324.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定