Greetings, I have done something I have never done before… git automation!
My Idea
I wanted to make changes to my website (kjycl.com
) in a more convenient manner and have things automated in case I just want to make quick changes because it is a long process to manually do a git push
and having to SSH into the VPS (cloud server) to git pull
changes.
So I decided to learn how to do automated deployment.
How I Did It
I switched cloud providers from one to another because it is–slightly–more powerful than my old one (let’s call it VPS-Data) and has a better system. I will still using the other cheap VPS (let’s call it VPS-Cheap) to run my website on (atleast for now until the next billing cycle for it, then I would switch to my new one)
I used to run self-hosted GitLab on one of my home servers, but it was resource heavy. Switching from
home --> VPS-Cheap
toVPS-Data --> VPS-Cheap
makes uploading changes a lot faster since data transfer between the two is typically 1gbps (~100 MB/s) while my internet is a mere 20mbps (~2 MB/s). Running this setup from server-to-server provides faster transfer.I decided to go with setting up Gitea on VPS-Data and migrated my repository over to there–which has just what I used GitLab for (basically the same but more lightweight).
I looked at some examples of Gitea’s CI/CD solution (works similar to GitHub Actions) and set up with their version called act runner for it to work.
By simply creating a file in
.gitea/workflows
calledworkflows.yml
, and filling it in with what for it to automate, I finally got it working! (After ~10 hours since I started working on this!)Total time from pushing from my computer (or merge to prod) to full deployment is about ~10 seconds.
Rough layout of
workflows.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
name: Hugo Website on: push: branches: - prod jobs: deploy: name: Build and deploy to prod runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Setup go uses: actions/setup-go@v4 with: go-version-file: "go.mod" - name: Setup everything env: HUGO_VERSION: 0.121.1 run: | ... - name: Build run: hugo --minify - name: Deploy env: ... run: | ...
Here’s an example of it in action (CI/CD):
Afterthoughts
My idea plan is to run a CDN seperate of kjycl.com’s host that has more storage, etc..; as of now, static content (ex. images and videos) is served directly from the host that this website is running on.
|
|
One step closer to being able to edit on mobile on the go!
Last updated: 2024-11-28 15:20 -0700