aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2024-03-10-using-custom-software-with-github-actions-to-deploy-a-site.md
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/2024-03-10-using-custom-software-with-github-actions-to-deploy-a-site.md')
-rw-r--r--content/posts/2024-03-10-using-custom-software-with-github-actions-to-deploy-a-site.md83
1 files changed, 83 insertions, 0 deletions
diff --git a/content/posts/2024-03-10-using-custom-software-with-github-actions-to-deploy-a-site.md b/content/posts/2024-03-10-using-custom-software-with-github-actions-to-deploy-a-site.md
new file mode 100644
index 0000000..bbf74fd
--- /dev/null
+++ b/content/posts/2024-03-10-using-custom-software-with-github-actions-to-deploy-a-site.md
@@ -0,0 +1,83 @@
1---
2title: "Using custom software with Github Actions to deploy a site"
3url: using-custom-software-with-github-actions-to-deploy-a-site.html
4date: 2024-03-10T15:30:11+01:00
5type: post
6draft: false
7---
8
9By default, GitHub uses Jekyll for their site generator which is fine,
10but it has some issues and the complexity is not really worth it for me.
11
12You could argue that Jekyll is simple, which it is to some degree,
13but it can become complicated quite quickly if you start adding your
14own spin on things.
15
16A while ago I wrote a simple static site generator called "[jbmafp -
17Just Build Me A Fucking Page](https://github.com/mitjafelicijan/jbmafp)"
18which was a protest against [Hugo](https://gohugo.io). Hugo is fine but
19again, if you try doing something that conflicts with the dogma they
20prescribe you are in trouble.
21
22I also moved this blog from self-hosted virtual machine to just GitHub
23Pages. I didn't want to bother myself managing that server anymore. And
24this presented a slight problem because I didn't want to use the default
25`_docs` folder GitHub wants you to use, and I also didn't want to upload
26`public` folder that gets generated to GitHub.
27
28Thankfully, there is a way to use custom software to generate your site
29like `jbmafp`.
30
31To achieve this you need to create a file `.github/workflows/deploy.yaml`
32in the root of your repository.
33
34```yaml
35name: Build and Deploy to Pages
36
37on:
38 push:
39 branches: ["master"]
40 workflow_dispatch:
41
42permissions:
43 contents: read
44 pages: write
45 id-token: write
46
47concurrency:
48 group: "pages"
49 cancel-in-progress: false
50
51jobs:
52 deploy:
53 environment:
54 name: github-pages
55 url: ${{ steps.deployment.outputs.page_url }}
56 runs-on: ubuntu-latest
57 steps:
58 - name: Checkout
59 uses: actions/checkout@v3
60 - name: Setup Pages
61 uses: actions/configure-pages@v3
62 - name: Run a multi-line script
63 run: |
64 wget https://github.com/mitjafelicijan/jbmafp/releases/download/v0.1/jbmafp.zip
65 unzip jbmafp.zip
66 chmod +x jbmafp
67 ./jbmafp -b
68 - name: Upload artifact
69 uses: actions/upload-pages-artifact@v2
70 with:
71 path: './public'
72 - name: Deploy to GitHub Pages
73 id: deployment
74 uses: actions/deploy-pages@v2
75```
76
77This is an example for `jbmafp`. When I execute `./jbmafp -b` the program
78creates `public` folder and puts all content there. And the directive
79`with: path: './public'` tells `actions/deploy-pages@v2` to look for
80`public` folder instead of `docs` folder.
81
82This can be used with anything, actually. Hugo, Gatsby, Astro, you
83name it.