Website rewrite and CI/CD hell
Hello, and welcome to a new blog post by the magical Instellate!
I decided to rewrite this website into something new, as I didn’t like the old one.
So what did I rewrite it into? Well glad you asked! It’s now in SvelteKit, tailwind and m3-svelte. Then I am just passing it through a static adapter to have it be static.
But was there anything else you learnt?
Yes! I decided to try and see if I can automate building and publishing to my VPS through GitHub Actions.
I thought it wouldn’t be too hard as I thought “Oh, surely the CI/CD ecosystem for GitHub has a lot of tools!“. Oh boy I was wrong.
Prelude
When I first made this website in SvelteKit I didn’t really think too much off it.
More than I want a new website. It was the end rush that when I decided to try CI/CD.
I knew some of my friends had done it with GitHub Actions (primarily D#+).
So I looked there to see a bit how to do. Then I just went with examples that was provided with GitHub actions.
Confusion
I succeded to make a system that builds and publish the static content as an artifact.
I then started looking for tools that might be able to grap this artifact and publish it on my VPS.
Low and behold there was no such tool. What I did next was look at the deployment documentation page provided by GitHub.
I read through the deployment page in GH, it isn’t too helpful.
From my understand it wanted me to use the actions to deploy it.
So I ended up finding a SFTP action. I thought I could use that to publish the artifact.
It did work, but I didn’t like it too much. I ended up discussing with some friends that are more knowledgable than me.
Anger
It tooks some time in anger discussion about how I should do it. In the end I ended up with changing it from building a docker image using nginx that serves static content.
This ended up taking some time, as I also decided “Hey I might need this for the future so let’s make it work for multiple projects.”
It took, 2 HOURS, of debugging to get a working version using TS and Express.
At the same time I found out that the gh cli on my VPS uses snap which does not work with git!
I ended up transferring files between SFTP cause I was just done for it and wanted to complete this.
The app works through GitHub webhook and docker compose files. It looks for workflow_run
event completion.
When it does it tries to look for a sub directory with the same repository name.
If it is found, it runs:
cd ../{repository name} && docker compose pull && docker compose down && docker compose up
It uses the GHCR registry for image hosting and works I guess? It’s still such a messy solution and I kinda hate it.
Conclusion
CI/CD is a hell! Is it worth setting up? Absolutely! Is there a lack of tools for deployment on VPS? Absolutely!
I would want to make a tool that makes it easier for developers that aren’t enteprise level to deploy.
But as school starts soon I will not be able too sadly. If anyone else finds a tool or is making one. PLEASE contact me.
I don’t trust the software I made for the deployment.