【问题标题】:Github Actions - Updating an HTML FileGithub Actions - 更新 HTML 文件
【发布时间】:2022-01-02 06:17:02
【问题描述】:

我有一个使用 Github Actions 部署的静态网站。该网站由 1 个 HTML 文件和几个 .yaml 配置文件组成。有一个简单的 javascript 函数可以加载所有 .yaml 文件。但是,目前 .yaml 文件列表是硬编码的。反正有没有:

  1. 在部署网站之前使用 Github Actions 更新 javascript 数组?
  2. 使用javascript根据config目录下的文件动态创建列表?

目录结构

index.html
config/
|-- first.yaml
|-- second.yaml
|-- ...

index.html

...
<script>
// how can we dynamically create this array?
var files = [
  {"name": "first.yaml"},
  {"name": "second.yaml"},
  ...
]
</script>

【问题讨论】:

  • 也许可以执行ls config 并将其传送到替换HTML 文件中的文件的sed 命令中?

标签: javascript github yaml github-actions


【解决方案1】:

使用这个: bluwy/substitute-string-action@v1

这是一个例子:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: bluwy/substitute-string-action@v1
      id: sub
      with:
        _input-text: 'Hello World!'
        World: GitHub

完整文档的操作网址: https://github.com/bluwy/substitute-string-action

https://i.stack.imgur.com/3wWvp.jpg

【讨论】:

  • 嗨 - 您能否提供一个示例,说明我的问题中的结构?我很难理解这是如何工作的。谢谢。
猜你喜欢
  • 2021-06-19
  • 1970-01-01
  • 2022-01-22
  • 2021-04-04
  • 1970-01-01
  • 2021-01-24
  • 2021-05-20
  • 2020-01-11
相关资源
最近更新 更多