简体   繁体   English

引用由 Github Actions 构建的工件

[英]Referencing an artifact built by Github Actions

The upload/download artifact documentation implies that one should be able to build into the dist folder. 上传/下载工件文档暗示应该能够构建到dist文件夹中。 My interpretation of this is that we can then reference this content in, for example, a static site, so that a site auto-builds itself for github pages on master pushes.我对此的解释是,然后我们可以在例如 static 站点中引用此内容,以便站点为主推送上的 github 页面自动构建自己。 However, it seems that artifacts are only uploaded to a specific location (ie GET /repos/{owner}/{repo}/actions/artifacts ) and can be downloaded only in zipped format, which defeats the purpose.但是,似乎工件仅上传到特定位置(即GET /repos/{owner}/{repo}/actions/artifacts )并且只能以压缩格式下载,这与目的不符。

Is there a way to populate the dist folder of the repo, so that the file that was built becomes publicly and permanently accessible as part of the repo, and I can reference it without having to deploy it elsewhere like S3 etc?有没有办法填充 repo 的dist文件夹,以便构建的文件作为 repo 的一部分成为公开和永久可访问的,我可以引用它而不必像 S3 等其他地方部署它?

Example例子

Here's a use case:这是一个用例:

  • I have a dashboard which parses some data from several remote locations and shows it in charts.我有一个仪表板,它解析来自几个远程位置的一些数据并将其显示在图表中。 The page is deployed from /docs because it's a Github Pages hosted page.该页面是从/docs部署的,因为它是 Github Pages 托管页面。
  • the web page only reads static, cached data from /docs/cache/dump.json . web 页面仅读取 static,缓存数据来自/docs/cache/dump.json
  • the dump.json file is generated via a scheduled Github Action which invokes a script that goes to the data sources and generates the dump. dump.json文件是通过计划的 Github 操作生成的,该操作调用进入数据源并生成转储的脚本。

This is how the web page can function quickly without on-page lockups due to lengthy data processing while the dump generation happes in the background.这就是 web 页面如何快速 function 没有由于冗长的数据处理而导致的页面锁定,而转储生成发生在后台。 The web page periodically re-reads the /docs/cache/dump.json file to get new data, which should override old data on every scheduled trigger. web 页面会定期重新读取/docs/cache/dump.json文件以获取新数据,该数据应在每个预定触发器上覆盖旧数据。

The idea is to have the action run and replace the dump.json file periodically, but all I can do is produce an artifact which I then have to manually fetch and unzip.这个想法是让操作运行并定期替换dump.json文件,但我所能做的就是生成一个工件,然后我必须手动获取并解压缩。 Ideally, it would just replace the current dump.json file in place.理想情况下,它只会替换当前的dump.json文件。

To persist changes made by a build process, it is necessary to add and commit them like after any change to a repo.要持久保存构建过程所做的更改,有必要像在对存储库进行任何更改之后一样添加和提交它们。 Several actions exist for this, like this one .为此存在几种操作,例如这个

So you would add the following to the workflow:因此,您将在工作流程中添加以下内容:

      - name: Commit changes
        uses: EndBug/add-and-commit@v7
        with:
          author_name: Commitobot
          author_email: my@mail.com
          message: "Updating build result!"
          add: "docs/cache/dump.json"

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

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