简体   繁体   English

Github 操作 - 更新 HTML 文件

[英]Github Actions - Updating an HTML File

I have a static website that I am deploying with Github Actions.我有一个 static 网站,我正在使用 Github 操作进行部署。 The website consists of 1 HTML file and several.yaml config files.该网站由 1 个 HTML 文件和几个.yaml 配置文件组成。 There is a simple javascript function that loads all the.yaml files.有一个简单的 javascript function 可以加载所有 .yaml 文件。 However, currently the list of.yaml files is hardcoded.但是,目前.yaml 文件的列表是硬编码的。 Is there anyway to either:反正有没有:

  1. Use Github Actions to update the javascript array before deploying the website?在部署网站之前使用 Github Actions 更新 javascript 阵列?
  2. Use javascript to dynamically create the list based on the files in the config directory?使用javascript根据config目录下的文件动态创建列表?

Directory structure目录结构

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

index.html索引.html

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

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

Here is an example: jobs: build: runs-on: ubuntu-latest steps: - uses: bluwy/substitute-string-action@v1 id: sub with: _input-text: 'Hello World:' World: GitHub这是一个示例:作业:构建:运行:ubuntu-latest 步骤:-使用:bluwy/substitute-string-action@v1 id:sub with:_input-text:'Hello World:' World:GitHub

Url to the action with the full docs: https://github.com/bluwy/substitute-string-action Url 到带有完整文档的操作: https://github.com/bluwy/substitute-string-action

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM