This commit is contained in:
Joshua Seigler 2025-06-15 13:26:30 -04:00
parent 82e4714724
commit 870aac7da6
7 changed files with 324 additions and 535 deletions

314
feed.xml
View file

@ -109,16 +109,18 @@
<p><code>/etc/caddy/Caddyfile</code></p> <p><code>/etc/caddy/Caddyfile</code></p>
<pre><code># Global options block <pre><code># Global options block
{ {
email you@example.com # <<<< change this email you@example.com # <<<< CHANGE THIS <<<<
on_demand_tls { on_demand_tls {
ask http://localhost/check ask http://localhost/check
} }
} }
omitted.webhooks.subdomain.tld { # <<<< change this # Webhooks
https://webhooks.subdomain.here.tld { <<<< CHANGE THIS <<<<
reverse_proxy localhost:9000 reverse_proxy localhost:9000
} }
# Filter for which SSL certs we will create. Prevents abuse.
http://localhost { http://localhost {
handle /check { handle /check {
root * /var/www root * /var/www
@ -127,13 +129,13 @@ http://localhost {
} }
} }
# This automatically handles upgrading http:// requests with a redirect
https:// { https:// {
tls { tls {
on_demand on_demand
} }
root /var/www root /var/www
rewrite /{host}{uri} rewrite /{host}{uri}
# Block files that start with a .
@forbidden { @forbidden {
path /.* path /.*
} }
@ -153,151 +155,61 @@ https:// {
<code>chown -R joshua:joshua /var/www</code> since the webhooks will run as my <code>chown -R joshua:joshua /var/www</code> since the webhooks will run as my
login account. login account.
</p> </p>
<h3 id="webhook" tabindex="-1"> <h3 id="webhooks" tabindex="-1">
<a <a
class="header-anchor" class="header-anchor"
href="https://joshua.seigler.net/posts/my-very-own-github-pages/#webhook" href="https://joshua.seigler.net/posts/my-very-own-github-pages/#webhooks"
aria-hidden="true" aria-hidden="true"
></a> ></a>
Webhook Webhooks
</h3> </h3>
<p> <p>In my home directory I defined two hook scripts:</p>
I altered the systemd service definition for <code>webhook</code> so I could <p><code>~/webhooks/update-pages.sh</code></p>
organize the hook definitions into separate files. I also set <pre><code class="language-bash">
<code>User=joshua</code> and <code>Group=joshua</code> so the commands run as #!/bin/bash
my user instead of root. # parameter 1 is repo name, parameter 2 is clone url
</p> [[ "$1" == *"/"* ]] && exit 1;
<p><code>sudo mkdir /etc/webhook.conf.d/</code></p> [[ "$1" == *".."* ]] && exit 1;
<p><code>/lib/systemd/system/webhook.service</code></p> [[ "$1" == *"*"* ]] && exit 1;
<pre><code class="language-ini">[Unit] if [ -d "/var/www/$1" ]; then
Description=Small server for creating HTTP endpoints (hooks) git clone -b gh-pages --single-branch "$2" "$1" || exit 1;
Documentation=https://github.com/adnanh/webhook/ exit;
ConditionPathExists=/etc/webhook.conf fi;
cd "/var/www/$1";
[Service] git fetch origin gh-pages;
ExecStart=/usr/bin/webhook -nopanic -hooks /etc/webhook.conf.d/*.conf git reset --hard origin/gh-pages;
exit;
User=joshua </code></pre>
Group=joshua <p><code>~/webhooks/remove-pages.sh</code></p>
<pre><code class="language-bash">#!/bin/bash
[Install] # parameter 1 is repo name
WantedBy=multi-user.target [[ "$1" == *"/"* ]] && exit 1;
[[ "$1" == *".."* ]] && exit 1;
[[ "$1" == *"*"* ]] && exit 1;
[ -d "/var/www/$1" ] || exit 1;
cd "/var/www";
rm -rf "/var/www/$1";
</code></pre> </code></pre>
<p> <p>
If you are debugging your webhook output, consider adding To trigger these hooks I am using <code>webhook</code> which is in the default
<code>-debug</code> next to <code>-nopanic</code> for more useful logs. Debian repository.
</p> </p>
<p> <p>
After changing the service definition, reload systemd to run the updated Here are the hook definitions: one for creating/updating a site, and one for
service: deleting. You will need to generate one or two secret values that the server
can use to know that the webhook is authorized to run. I used linux command
<code>uuidgen -r</code> to create mine. Save these values so you can enter
them in Forgejo later.
</p> </p>
<pre><code class="language-bash">sudo systemctl daemon-reload <p>
</code></pre> Also make sure to replace your execute-command lines with ones referencing
<p>Then you can remove the now-unused config file:</p> your username and script paths.
<pre><code class="language-bash">sudo rm /etc/webhook.conf </p>
</code></pre> <p><code>/etc/webhook.conf</code></p>
<p>Here are the three hook definitions:</p>
<h4 id="create-pages" tabindex="-1">
<a
class="header-anchor"
href="https://joshua.seigler.net/posts/my-very-own-github-pages/#create-pages"
aria-hidden="true"
></a>
Create pages
</h4>
<p><code>/etc/webhook.conf.d/create-pages.conf</code></p>
<pre><code class="language-json">[
{
"id": "create-pages",
"execute-command": "/home/joshua/webhooks/create-pages.sh",
"command-working-directory": "/var/www",
"pass-arguments-to-command":
[
{
"source": "payload",
"name": "repository.name"
},
{
"source": "payload",
"name": "clone_url",
}
],
"trigger-rule":
{
"and":
[
{
"match":
{
"type": "payload-hmac-sha256",
"secret": "(omitted)",
"parameter":
{
"source": "header",
"name": "X-Forgejo-Signature"
}
}
}
]
}
}
]
</code></pre>
<h4 id="remove-pages" tabindex="-1">
<a
class="header-anchor"
href="https://joshua.seigler.net/posts/my-very-own-github-pages/#remove-pages"
aria-hidden="true"
></a>
Remove pages
</h4>
<p><code>/etc/webhook.conf.d/remove-pages.conf</code></p>
<pre><code class="language-json">[
{
"id": "remove-pages",
"execute-command": "/home/joshua/webhooks/remove-pages.sh",
"command-working-directory": "/var/www",
"pass-arguments-to-command":
[
{
"source": "payload",
"name": "repository.name"
},
],
"trigger-rule":
{
"and":
[
{
"match":
{
"type": "payload-hmac-sha256",
"secret": "(omitted)",
"parameter":
{
"source": "header",
"name": "X-Forgejo-Signature"
}
}
}
]
}
}
]
</code></pre>
<h4 id="update-pages" tabindex="-1">
<a
class="header-anchor"
href="https://joshua.seigler.net/posts/my-very-own-github-pages/#update-pages"
aria-hidden="true"
></a>
Update pages
</h4>
<p><code>/etc/webhook.conf.d/update-pages.conf</code></p>
<pre><code class="language-json">[ <pre><code class="language-json">[
{ {
"id": "update-pages", "id": "update-pages",
"execute-command": "/home/joshua/webhooks/update-pages.sh", "execute-command": "su joshua /home/joshua/webhooks/update-pages.sh",
"command-working-directory": "/var/www", "command-working-directory": "/var/www",
"pass-arguments-to-command": "pass-arguments-to-command":
[ [
@ -336,42 +248,39 @@ WantedBy=multi-user.target
} }
] ]
} }
},
{
"id": "remove-pages",
"execute-command": "su joshua /home/joshua/webhooks/remove-pages.sh",
"command-working-directory": "/var/www",
"pass-arguments-to-command":
[
{
"source": "payload",
"name": "repository.name"
},
],
"trigger-rule":
{
"and":
[
{
"match":
{
"type": "payload-hmac-sha256",
"secret": "(omitted)",
"parameter":
{
"source": "header",
"name": "X-Forgejo-Signature"
}
}
}
]
}
} }
] ]
</code></pre> </code></pre>
<p>In my home directory I defined all three hook scripts:</p>
<p><code>webhooks/create-pages.sh</code></p>
<pre><code class="language-bash">#!/bin/bash
# parameter 1 is repo name, parameter 2 is clone URL
[[ "$1" == *"/"* ]] && exit 1; # no slashes in the name
[[ "$1" == *".."* ]] && exit 1; # no .. in the name
[[ "$1" == *"*"* ]] && exit 1; # no wildcards in the name
[ -d "/var/www/$1" ] && exit 1; # the directory must not exist
cd "/var/www";
git clone -b gh-pages --single-branch "$2" "$1" || exit 1;
</code></pre>
<p><code>webhooks/remove-pages.sh</code></p>
<pre><code class="language-bash">#!/bin/bash
# parameter 1 is repo name
[[ "$1" == *"/"* ]] && exit 1; # no slashes in the name
[[ "$1" == *".."* ]] && exit 1; # no .. in the name
[[ "$1" == *"*"* ]] && exit 1; # no wildcards in the name
[ -d "/var/www/$1" ] && exit 1; # the directory must exist
cd "/var/www";
rm -rf "/var/www/$1";
</code></pre>
<p><code>webhooks/update-pages.sh</code></p>
<pre><code class="language-bash">#!/bin/bash
# parameter 1 is repo name
[[ "$1" == *"/"* ]] && exit 1; # no slashes in the name
[[ "$1" == *".."* ]] && exit 1; # no .. in the name
[[ "$1" == *"*"* ]] && exit 1; # no wildcards in the name
[ -d "/var/www/$1" ] || exit 1; # the directory must exist
cd "/var/www/$1";
git fetch origin gh-pages;
git reset --hard origin/gh-pages;
exit;
</code></pre>
<h3 id="forgejo" tabindex="-1"> <h3 id="forgejo" tabindex="-1">
<a <a
class="header-anchor" class="header-anchor"
@ -385,42 +294,10 @@ exit;
conditions.<br /> conditions.<br />
Under my main user settings I set up each webhook: Under my main user settings I set up each webhook:
</p> </p>
<h4 id="create-pages-1" tabindex="-1"> <h4 id="update-pages" tabindex="-1">
<a <a
class="header-anchor" class="header-anchor"
href="https://joshua.seigler.net/posts/my-very-own-github-pages/#create-pages-1" href="https://joshua.seigler.net/posts/my-very-own-github-pages/#update-pages"
aria-hidden="true"
></a>
Create pages
</h4>
<p>
Target URL: https:// <em>your domain here</em> /hooks/create-pages<br />
HTTP Method: <code>POST</code> (the default)<br />
POST content type: <code>application/json</code> (the default)<br />
Secret: <em>omitted, use your own</em><br />
Trigger on: Custom Events > Create<br />
Branch filter: <code>gh-pages</code>
</p>
<h4 id="remove-pages-1" tabindex="-1">
<a
class="header-anchor"
href="https://joshua.seigler.net/posts/my-very-own-github-pages/#remove-pages-1"
aria-hidden="true"
></a>
Remove pages
</h4>
<p>
Target URL: https:// <em>your domain here</em> /hooks/remove-pages<br />
HTTP Method: <code>POST</code> (the default)<br />
POST content type: <code>application/json</code> (the default)<br />
Secret: <em>omitted, use your own</em><br />
Trigger on: Custom Events > Repository > Delete<br />
Branch filter: <code>gh-pages</code>
</p>
<h4 id="update-pages-1" tabindex="-1">
<a
class="header-anchor"
href="https://joshua.seigler.net/posts/my-very-own-github-pages/#update-pages-1"
aria-hidden="true" aria-hidden="true"
></a> ></a>
Update pages Update pages
@ -433,6 +310,22 @@ exit;
Trigger on: Push events<br /> Trigger on: Push events<br />
Branch filter: <code>gh-pages</code> Branch filter: <code>gh-pages</code>
</p> </p>
<h4 id="remove-pages" tabindex="-1">
<a
class="header-anchor"
href="https://joshua.seigler.net/posts/my-very-own-github-pages/#remove-pages"
aria-hidden="true"
></a>
Remove pages
</h4>
<p>
Target URL: https:// <em>your domain here</em> /hooks/remove-pages<br />
HTTP Method: <code>POST</code> (the default)<br />
POST content type: <code>application/json</code> (the default)<br />
Secret: <em>omitted, use your own</em><br />
Trigger on: Custom Events > Repository > Delete<br />
Branch filter: <code>gh-pages</code>
</p>
<h2 id="conclusion" tabindex="-1"> <h2 id="conclusion" tabindex="-1">
<a <a
class="header-anchor" class="header-anchor"
@ -456,25 +349,18 @@ exit;
> >
</p> </p>
<p> <p>
There is room to make the scripts a little smarter. They dont handle renaming For repos with npm build scripts, I use
very well right now, and a few times I had to log in and manually run my
webhook scripts, like this:
</p>
<pre><code class="language-bash">~/webhooks/create-pages.sh marklink.pages.seigler.net "https://git.apps.seigler.net/joshua/marklink.pages.seigler.net.git"
</code></pre>
<p>
The really important thing is that updates just require pushing to
<code>gh-pages</code> which you can easily do with e.g.
<a <a
href="https://www.npmjs.com/package/gh-pages" href="https://www.npmjs.com/package/gh-pages"
target="_blank" target="_blank"
rel="noopener" rel="noopener"
>gh-pages @ npm</a >gh-pages @ npm</a
>. >
to push the build to the gh-pages branch and up to the server.
</p> </p>
<p> <p>
Im also putting off rolling my own CI server, but I imagine thats the next Im putting off rolling my own CI server, but I imagine thats the next stage
stage here. Stay tuned. here. Stay tuned.
</p> </p>
</content> </content>
</entry> </entry>

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"version":"1.3.0","languages":{"en":{"hash":"en_e6a3ea1351","wasm":"en","page_count":26}}} {"version":"1.3.0","languages":{"en":{"hash":"en_9ba5dde7b9","wasm":"en","page_count":26}}}

Binary file not shown.

View file

@ -177,16 +177,18 @@
<p><code>/etc/caddy/Caddyfile</code></p> <p><code>/etc/caddy/Caddyfile</code></p>
<pre><code># Global options block <pre><code># Global options block
{ {
email you@example.com # &lt;&lt;&lt;&lt; change this email you@example.com # &lt;&lt;&lt;&lt; CHANGE THIS &lt;&lt;&lt;&lt;
on_demand_tls { on_demand_tls {
ask http://localhost/check ask http://localhost/check
} }
} }
omitted.webhooks.subdomain.tld { # &lt;&lt;&lt;&lt; change this # Webhooks
https://webhooks.subdomain.here.tld { &lt;&lt;&lt;&lt; CHANGE THIS &lt;&lt;&lt;&lt;
reverse_proxy localhost:9000 reverse_proxy localhost:9000
} }
# Filter for which SSL certs we will create. Prevents abuse.
http://localhost { http://localhost {
handle /check { handle /check {
root * /var/www root * /var/www
@ -195,13 +197,13 @@ http://localhost {
} }
} }
# This automatically handles upgrading http:// requests with a redirect
https:// { https:// {
tls { tls {
on_demand on_demand
} }
root /var/www root /var/www
rewrite /{host}{uri} rewrite /{host}{uri}
# Block files that start with a .
@forbidden { @forbidden {
path /.* path /.*
} }
@ -221,134 +223,57 @@ https:// {
<code>chown -R joshua:joshua /var/www</code> since the webhooks will run <code>chown -R joshua:joshua /var/www</code> since the webhooks will run
as my login account. as my login account.
</p> </p>
<h3 id="webhook" tabindex="-1"> <h3 id="webhooks" tabindex="-1">
<a class="header-anchor" href="#webhook" aria-hidden="true"></a> Webhook <a class="header-anchor" href="#webhooks" aria-hidden="true"></a>
Webhooks
</h3> </h3>
<p> <p>In my home directory I defined two hook scripts:</p>
I altered the systemd service definition for <code>webhook</code> so I <p><code>~/webhooks/update-pages.sh</code></p>
could organize the hook definitions into separate files. I also set <pre><code class="language-bash">
<code>User=joshua</code> and <code>Group=joshua</code> so the commands #!/bin/bash
run as my user instead of root. # parameter 1 is repo name, parameter 2 is clone url
</p> [[ &quot;$1&quot; == *&quot;/&quot;* ]] &amp;&amp; exit 1;
<p><code>sudo mkdir /etc/webhook.conf.d/</code></p> [[ &quot;$1&quot; == *&quot;..&quot;* ]] &amp;&amp; exit 1;
<p><code>/lib/systemd/system/webhook.service</code></p> [[ &quot;$1&quot; == *&quot;*&quot;* ]] &amp;&amp; exit 1;
<pre><code class="language-ini">[Unit] if [ -d &quot;/var/www/$1&quot; ]; then
Description=Small server for creating HTTP endpoints (hooks) git clone -b gh-pages --single-branch &quot;$2&quot; &quot;$1&quot; || exit 1;
Documentation=https://github.com/adnanh/webhook/ exit;
ConditionPathExists=/etc/webhook.conf fi;
cd &quot;/var/www/$1&quot;;
[Service] git fetch origin gh-pages;
ExecStart=/usr/bin/webhook -nopanic -hooks /etc/webhook.conf.d/*.conf git reset --hard origin/gh-pages;
exit;
User=joshua </code></pre>
Group=joshua <p><code>~/webhooks/remove-pages.sh</code></p>
<pre><code class="language-bash">#!/bin/bash
[Install] # parameter 1 is repo name
WantedBy=multi-user.target [[ &quot;$1&quot; == *&quot;/&quot;* ]] &amp;&amp; exit 1;
[[ &quot;$1&quot; == *&quot;..&quot;* ]] &amp;&amp; exit 1;
[[ &quot;$1&quot; == *&quot;*&quot;* ]] &amp;&amp; exit 1;
[ -d &quot;/var/www/$1&quot; ] || exit 1;
cd &quot;/var/www&quot;;
rm -rf &quot;/var/www/$1&quot;;
</code></pre> </code></pre>
<p> <p>
If you are debugging your webhook output, consider adding To trigger these hooks I am using <code>webhook</code> which is in the
<code>-debug</code> next to <code>-nopanic</code> for more useful logs. default Debian repository.
</p> </p>
<p> <p>
After changing the service definition, reload systemd to run the updated Here are the hook definitions: one for creating/updating a site, and one
service: for deleting. You will need to generate one or two secret values that
the server can use to know that the webhook is authorized to run. I used
linux command <code>uuidgen -r</code> to create mine. Save these values
so you can enter them in Forgejo later.
</p> </p>
<pre><code class="language-bash">sudo systemctl daemon-reload <p>
</code></pre> Also make sure to replace your execute-command lines with ones
<p>Then you can remove the now-unused config file:</p> referencing your username and script paths.
<pre><code class="language-bash">sudo rm /etc/webhook.conf </p>
</code></pre> <p><code>/etc/webhook.conf</code></p>
<p>Here are the three hook definitions:</p>
<h4 id="create-pages" tabindex="-1">
<a class="header-anchor" href="#create-pages" aria-hidden="true"></a>
Create pages
</h4>
<p><code>/etc/webhook.conf.d/create-pages.conf</code></p>
<pre><code class="language-json">[
{
&quot;id&quot;: &quot;create-pages&quot;,
&quot;execute-command&quot;: &quot;/home/joshua/webhooks/create-pages.sh&quot;,
&quot;command-working-directory&quot;: &quot;/var/www&quot;,
&quot;pass-arguments-to-command&quot;:
[
{
&quot;source&quot;: &quot;payload&quot;,
&quot;name&quot;: &quot;repository.name&quot;
},
{
&quot;source&quot;: &quot;payload&quot;,
&quot;name&quot;: &quot;clone_url&quot;,
}
],
&quot;trigger-rule&quot;:
{
&quot;and&quot;:
[
{
&quot;match&quot;:
{
&quot;type&quot;: &quot;payload-hmac-sha256&quot;,
&quot;secret&quot;: &quot;(omitted)&quot;,
&quot;parameter&quot;:
{
&quot;source&quot;: &quot;header&quot;,
&quot;name&quot;: &quot;X-Forgejo-Signature&quot;
}
}
}
]
}
}
]
</code></pre>
<h4 id="remove-pages" tabindex="-1">
<a class="header-anchor" href="#remove-pages" aria-hidden="true"></a>
Remove pages
</h4>
<p><code>/etc/webhook.conf.d/remove-pages.conf</code></p>
<pre><code class="language-json">[
{
&quot;id&quot;: &quot;remove-pages&quot;,
&quot;execute-command&quot;: &quot;/home/joshua/webhooks/remove-pages.sh&quot;,
&quot;command-working-directory&quot;: &quot;/var/www&quot;,
&quot;pass-arguments-to-command&quot;:
[
{
&quot;source&quot;: &quot;payload&quot;,
&quot;name&quot;: &quot;repository.name&quot;
},
],
&quot;trigger-rule&quot;:
{
&quot;and&quot;:
[
{
&quot;match&quot;:
{
&quot;type&quot;: &quot;payload-hmac-sha256&quot;,
&quot;secret&quot;: &quot;(omitted)&quot;,
&quot;parameter&quot;:
{
&quot;source&quot;: &quot;header&quot;,
&quot;name&quot;: &quot;X-Forgejo-Signature&quot;
}
}
}
]
}
}
]
</code></pre>
<h4 id="update-pages" tabindex="-1">
<a class="header-anchor" href="#update-pages" aria-hidden="true"></a>
Update pages
</h4>
<p><code>/etc/webhook.conf.d/update-pages.conf</code></p>
<pre><code class="language-json">[ <pre><code class="language-json">[
{ {
&quot;id&quot;: &quot;update-pages&quot;, &quot;id&quot;: &quot;update-pages&quot;,
&quot;execute-command&quot;: &quot;/home/joshua/webhooks/update-pages.sh&quot;, &quot;execute-command&quot;: &quot;su joshua /home/joshua/webhooks/update-pages.sh&quot;,
&quot;command-working-directory&quot;: &quot;/var/www&quot;, &quot;command-working-directory&quot;: &quot;/var/www&quot;,
&quot;pass-arguments-to-command&quot;: &quot;pass-arguments-to-command&quot;:
[ [
@ -387,41 +312,38 @@ WantedBy=multi-user.target
} }
] ]
} }
},
{
&quot;id&quot;: &quot;remove-pages&quot;,
&quot;execute-command&quot;: &quot;su joshua /home/joshua/webhooks/remove-pages.sh&quot;,
&quot;command-working-directory&quot;: &quot;/var/www&quot;,
&quot;pass-arguments-to-command&quot;:
[
{
&quot;source&quot;: &quot;payload&quot;,
&quot;name&quot;: &quot;repository.name&quot;
},
],
&quot;trigger-rule&quot;:
{
&quot;and&quot;:
[
{
&quot;match&quot;:
{
&quot;type&quot;: &quot;payload-hmac-sha256&quot;,
&quot;secret&quot;: &quot;(omitted)&quot;,
&quot;parameter&quot;:
{
&quot;source&quot;: &quot;header&quot;,
&quot;name&quot;: &quot;X-Forgejo-Signature&quot;
}
}
}
]
}
} }
] ]
</code></pre>
<p>In my home directory I defined all three hook scripts:</p>
<p><code>webhooks/create-pages.sh</code></p>
<pre><code class="language-bash">#!/bin/bash
# parameter 1 is repo name, parameter 2 is clone URL
[[ &quot;$1&quot; == *&quot;/&quot;* ]] &amp;&amp; exit 1; # no slashes in the name
[[ &quot;$1&quot; == *&quot;..&quot;* ]] &amp;&amp; exit 1; # no .. in the name
[[ &quot;$1&quot; == *&quot;*&quot;* ]] &amp;&amp; exit 1; # no wildcards in the name
[ -d &quot;/var/www/$1&quot; ] &amp;&amp; exit 1; # the directory must not exist
cd &quot;/var/www&quot;;
git clone -b gh-pages --single-branch &quot;$2&quot; &quot;$1&quot; || exit 1;
</code></pre>
<p><code>webhooks/remove-pages.sh</code></p>
<pre><code class="language-bash">#!/bin/bash
# parameter 1 is repo name
[[ &quot;$1&quot; == *&quot;/&quot;* ]] &amp;&amp; exit 1; # no slashes in the name
[[ &quot;$1&quot; == *&quot;..&quot;* ]] &amp;&amp; exit 1; # no .. in the name
[[ &quot;$1&quot; == *&quot;*&quot;* ]] &amp;&amp; exit 1; # no wildcards in the name
[ -d &quot;/var/www/$1&quot; ] &amp;&amp; exit 1; # the directory must exist
cd &quot;/var/www&quot;;
rm -rf &quot;/var/www/$1&quot;;
</code></pre>
<p><code>webhooks/update-pages.sh</code></p>
<pre><code class="language-bash">#!/bin/bash
# parameter 1 is repo name
[[ &quot;$1&quot; == *&quot;/&quot;* ]] &amp;&amp; exit 1; # no slashes in the name
[[ &quot;$1&quot; == *&quot;..&quot;* ]] &amp;&amp; exit 1; # no .. in the name
[[ &quot;$1&quot; == *&quot;*&quot;* ]] &amp;&amp; exit 1; # no wildcards in the name
[ -d &quot;/var/www/$1&quot; ] || exit 1; # the directory must exist
cd &quot;/var/www/$1&quot;;
git fetch origin gh-pages;
git reset --hard origin/gh-pages;
exit;
</code></pre> </code></pre>
<h3 id="forgejo" tabindex="-1"> <h3 id="forgejo" tabindex="-1">
<a class="header-anchor" href="#forgejo" aria-hidden="true"></a> Forgejo <a class="header-anchor" href="#forgejo" aria-hidden="true"></a> Forgejo
@ -431,32 +353,8 @@ exit;
conditions.<br /> conditions.<br />
Under my main user settings I set up each webhook: Under my main user settings I set up each webhook:
</p> </p>
<h4 id="create-pages-1" tabindex="-1"> <h4 id="update-pages" tabindex="-1">
<a class="header-anchor" href="#create-pages-1" aria-hidden="true"></a> <a class="header-anchor" href="#update-pages" aria-hidden="true"></a>
Create pages
</h4>
<p>
Target URL: https:// <em>your domain here</em> /hooks/create-pages<br />
HTTP Method: <code>POST</code> (the default)<br />
POST content type: <code>application/json</code> (the default)<br />
Secret: <em>omitted, use your own</em><br />
Trigger on: Custom Events &gt; Create<br />
Branch filter: <code>gh-pages</code>
</p>
<h4 id="remove-pages-1" tabindex="-1">
<a class="header-anchor" href="#remove-pages-1" aria-hidden="true"></a>
Remove pages
</h4>
<p>
Target URL: https:// <em>your domain here</em> /hooks/remove-pages<br />
HTTP Method: <code>POST</code> (the default)<br />
POST content type: <code>application/json</code> (the default)<br />
Secret: <em>omitted, use your own</em><br />
Trigger on: Custom Events &gt; Repository &gt; Delete<br />
Branch filter: <code>gh-pages</code>
</p>
<h4 id="update-pages-1" tabindex="-1">
<a class="header-anchor" href="#update-pages-1" aria-hidden="true"></a>
Update pages Update pages
</h4> </h4>
<p> <p>
@ -467,6 +365,18 @@ exit;
Trigger on: Push events<br /> Trigger on: Push events<br />
Branch filter: <code>gh-pages</code> Branch filter: <code>gh-pages</code>
</p> </p>
<h4 id="remove-pages" tabindex="-1">
<a class="header-anchor" href="#remove-pages" aria-hidden="true"></a>
Remove pages
</h4>
<p>
Target URL: https:// <em>your domain here</em> /hooks/remove-pages<br />
HTTP Method: <code>POST</code> (the default)<br />
POST content type: <code>application/json</code> (the default)<br />
Secret: <em>omitted, use your own</em><br />
Trigger on: Custom Events &gt; Repository &gt; Delete<br />
Branch filter: <code>gh-pages</code>
</p>
<h2 id="conclusion" tabindex="-1"> <h2 id="conclusion" tabindex="-1">
<a class="header-anchor" href="#conclusion" aria-hidden="true"></a> <a class="header-anchor" href="#conclusion" aria-hidden="true"></a>
Conclusion Conclusion
@ -489,25 +399,18 @@ exit;
> >
</p> </p>
<p> <p>
There is room to make the scripts a little smarter. They dont handle For repos with npm build scripts, I use
renaming very well right now, and a few times I had to log in and
manually run my webhook scripts, like this:
</p>
<pre><code class="language-bash">~/webhooks/create-pages.sh marklink.pages.seigler.net &quot;https://git.apps.seigler.net/joshua/marklink.pages.seigler.net.git&quot;
</code></pre>
<p>
The really important thing is that updates just require pushing to
<code>gh-pages</code> which you can easily do with e.g.
<a <a
href="https://www.npmjs.com/package/gh-pages" href="https://www.npmjs.com/package/gh-pages"
target="_blank" target="_blank"
rel="noopener" rel="noopener"
>gh-pages @ npm</a >gh-pages @ npm</a
>. >
to push the build to the gh-pages branch and up to the server.
</p> </p>
<p> <p>
Im also putting off rolling my own CI server, but I imagine thats the Im putting off rolling my own CI server, but I imagine thats the next
next stage here. Stay tuned. stage here. Stay tuned.
</p> </p>
<script <script

View file

@ -228,7 +228,7 @@
<url> <url>
<loc>/feed.xml</loc> <loc>/feed.xml</loc>
<lastmod>2025-06-15T05:22:58.508Z</lastmod> <lastmod>2025-06-15T17:26:28.478Z</lastmod>
</url> </url>