简体   繁体   中英

Referencing an artifact built by Github Actions

The upload/download artifact documentation implies that one should be able to build into the dist folder. 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. 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.

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?

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.
  • the web page only reads static, cached data from /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.

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. 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.

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. Ideally, it would just replace the current dump.json file in place.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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