Skip to main content

Static Hosting

We have tutorials to help you set up static hosting for various types of build outputs:

About the static_hosting plugin

Sample task configuration:

.stoat/config.yaml
---
version: 1
enabled: true
plugins:
static_hosting:
docs:
metadata:
name: Documentation
path: build/static-docs

Here, docs is the user-chosen task id. This should be unique across all of the configured plugins.

The metadata key can contain any information that you want to use for templating. However, the name key is optionally used by the default template to show the list of statically hosted build artifacts.

The docs key contains the required path. This path is specified from the root of the Git repository and can either reference a file or a directory.

After Stoat aggregates build data to render the comment, something like this will be used for templating:

---
version: 1
enabled: true
plugins:
static_hosting:
docs:
metadata:
name: Documentation
path: build/static-docs
sha: "1848b03dd4b58c8f8485d51a2157af4904e4073f"
link: "https://some-path-here.stoat.page"
status: "✅"

As you can see, Stoat adds on some information that allows you to access the hosted artifact or view information about the build that produced the artifact. Note that all information in your metadata field will be passed through.

That means, in your comment template you can use any metadata value or value under the task id docs to render the comment.

For example, the following template could be used to add a link to the file in the Stoat comment:

[{{ plugins.static_hosting.docs.metadata.name }}]({{ plugins.static_hosting.docs.link }})

Or, if the uploaded file was an image that could be embedded, the following template could be used to render the image inline:

![{{ plugins.static_hosting.taskid.metadata.name }}]({{ plugins.static_hosting.taskid.link }})

Default template

If you'd like to just get a table of all build outputs configured with the static_hosting plugin, we recommend using:

{{{ views.plugins.static_hosting.github.table }}}

Under the hood, this uses the following template:

## Static Hosting

| Name | Link | Commit | Status |
| :--- | :--- | :--: | :-----: |
{{#each plugins.static_hosting}}
{{#if this.status ~}}
| **{{#if this.metadata.name}}{{{ this.metadata.name }}}{{else}}{{ @key }}{{/if}}** | [Visit]({{ this.link }}) | {{ this.sha }} | {{{ this.status }}} |
{{/if ~}}
{{/each}}

Local previews

Our CLI can run static hosting using your local build results. View our local previews guide for more information.