healthchecks_healthchecks/templates/docs/github_actions.html-fragment
Pēteris Caune b9996e63c8
Fix django-compressor warning with github_actions.html
HTML files in /templates/docs/ are not Django templates,
they contain HTML content to be used verbatim in
hc.front.views.serve_doc view.

Some of these files contain "{{ ... }}" syntax. When
we run "./manage.py compress", django-compressor trips
up on this syntax because it treats them as Django templates.

The fix is to change file extension for these files
from .html to something else (I picked .html-fragment)
so django-compressor would ignore them.
2023-04-11 20:34:31 +03:00

63 lines
7.7 KiB
Plaintext

<h1>GitHub Actions</h1>
<p>You can augment your GitHub Actions workflows to report success and
failure to SITE_NAME:</p>
<div class="highlight"><pre><span></span><code><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Hourly Housekeeping</span>
<span class="nt">on</span><span class="p">:</span>
<span class="w"> </span><span class="nt">schedule</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">cron</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;15</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">*&#39;</span>
<span class="nt">jobs</span><span class="p">:</span>
<span class="w"> </span><span class="nt">Main-Job</span><span class="p">:</span>
<span class="w"> </span><span class="nt">runs-on</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">ubuntu-latest</span>
<span class="w"> </span><span class="nt">steps</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">run</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">echo &quot;Running housekeeping tasks...&quot;</span>
<span class="w"> </span><span class="nt">Ping-Success</span><span class="p">:</span>
<span class="w"> </span><span class="nt">runs-on</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">ubuntu-latest</span>
<span class="w"> </span><span class="nt">needs</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">[</span><span class="nv">Main-Job</span><span class="p p-Indicator">]</span>
<span class="w"> </span><span class="nt">steps</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">run</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">curl -m 10 --retry 5 ${{ secrets.ping_url }}</span>
<span class="w"> </span><span class="nt">Ping-Failure</span><span class="p">:</span>
<span class="w"> </span><span class="nt">runs-on</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">ubuntu-latest</span>
<span class="w"> </span><span class="nt">if</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">${{ failure() }}</span>
<span class="w"> </span><span class="nt">needs</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">[</span><span class="nv">Main-Job</span><span class="p p-Indicator">]</span>
<span class="w"> </span><span class="nt">steps</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">run</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">curl -m 10 --retry 5 ${{ secrets.ping_url }}/fail</span>
</code></pre></div>
<p>Note how the jobs <code>Ping-Success</code> and <code>Ping-Failure</code> define <code>Main-Job</code> as
their dependency. <code>Ping-Success</code> runs only if <code>Main-Job</code> completes
successfully, and <code>Ping-Failure</code> runs when <code>Main-Job</code> fails.</p>
<p>To avoid exposing the ping URL, it is a good idea to define it
as <a href="https://docs.github.com/en/actions/security-guides/encrypted-secrets">a secret</a>
and access it via the <code>secrets</code> context.</p>
<h2>Using the <code>workflow_run</code> Trigger</h2>
<p>Alternatively, you can put the pinging logic in a separate workflow,
and configure it to trigger every time your main workflow finishes. The main workflow:</p>
<div class="highlight"><pre><span></span><code><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Hourly Housekeeping</span>
<span class="nt">on</span><span class="p">:</span>
<span class="w"> </span><span class="nt">schedule</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">cron</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;15</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">*&#39;</span>
<span class="nt">jobs</span><span class="p">:</span>
<span class="w"> </span><span class="nt">Main-Job</span><span class="p">:</span>
<span class="w"> </span><span class="nt">runs-on</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">ubuntu-latest</span>
<span class="w"> </span><span class="nt">steps</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">run</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">echo &quot;Running housekeeping tasks...&quot;</span>
</code></pre></div>
<p>And the monitoring workflow:</p>
<div class="highlight"><pre><span></span><code><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Ping SITE_NAME</span>
<span class="nt">on</span><span class="p">:</span>
<span class="w"> </span><span class="nt">workflow_run</span><span class="p">:</span>
<span class="w"> </span><span class="nt">workflows</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">[</span><span class="s">&#39;Hourly</span><span class="nv"> </span><span class="s">Housekeeping&#39;</span><span class="p p-Indicator">]</span>
<span class="w"> </span><span class="nt">types</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">[</span><span class="nv">completed</span><span class="p p-Indicator">]</span>
<span class="nt">jobs</span><span class="p">:</span>
<span class="w"> </span><span class="nt">Ping-Success</span><span class="p">:</span>
<span class="w"> </span><span class="nt">runs-on</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">ubuntu-latest</span>
<span class="w"> </span><span class="nt">if</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">${{ github.event.workflow_run.conclusion == &#39;success&#39; }}</span>
<span class="w"> </span><span class="nt">steps</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">run</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">curl -m 10 --retry 5 ${{ secrets.ping_url }}</span>
<span class="w"> </span><span class="nt">Ping-Failure</span><span class="p">:</span>
<span class="w"> </span><span class="nt">runs-on</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">ubuntu-latest</span>
<span class="w"> </span><span class="nt">if</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">${{ github.event.workflow_run.conclusion == &#39;failure&#39; }}</span>
<span class="w"> </span><span class="nt">steps</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">run</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">curl -m 10 --retry 5 ${{ secrets.ping_url }}/fail</span>
</code></pre></div>