From ce4124fdf2e1c505b308cc1e04f258650f2f039f Mon Sep 17 00:00:00 2001 From: Ozoniuss Date: Sat, 5 Oct 2024 16:13:29 +0300 Subject: [PATCH] First page powered by pipeline Hoping to see it update. --- src/blog/I-have-a-ci-cd-pipeline/index.html | 78 +++++++++++++++++++++ src/blog/index.html | 3 + 2 files changed, 81 insertions(+) create mode 100644 src/blog/I-have-a-ci-cd-pipeline/index.html diff --git a/src/blog/I-have-a-ci-cd-pipeline/index.html b/src/blog/I-have-a-ci-cd-pipeline/index.html new file mode 100644 index 0000000..4413234 --- /dev/null +++ b/src/blog/I-have-a-ci-cd-pipeline/index.html @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + This page was powered by pipeline + + + +
+ + +
+
+ +

I finally have a Github CI/CD pipeline to update my site automatically

+ +

+ I was planning to do this for quite some time now. In fact, I've had an open issue for this for the last 6 months. I really slacked on the website lately, mainly because I was going through some issues at work, and have tried experimenting with Github pages as an alternative. But I finally found another use case that would be perfect for the website, which prompted me to finally get the CI/CD pipeline done with. +

+ +

+ The idea is simple: my site is a static website in Backblaze B2 powered by Cloudflare (I'll explain in some post how I did it). Any changes to the bucket would eventually be reflected on the published website. So the idea is pretty simple: keep the bucket synced with the Github repository. This comes for granted with solutions like Github pages, but when I first did the website I had an unhealthy desire to do everything from scratch, so I have to implement simple things like this by myself. But hey, at least I practice my yaml skills. +

+ +

+ I originally wanted to do this with rclone, mainly because I have experience with it. That's how I've been syncing my website manually so far. But, rclone requires a config file to read the remotes you have access to, and I've configured several remotes. I know you can store secrets in Github, but I didn't want my whole config to be there, just in case. I wasn't able to find an easy way to configure rclone to be able to interact only with a single remote (such as maybe setting some env vars for the commands, idk) so I looked for an alternative. Luckily, Backblaze does have a CLI tool which allows you to sync your files easily, whilst also configuring authorization for a single bucket. This is what I went with. +

+ +

+ The script is pretty simple and runs whenever I make a new commit. You can find it below. + +name: Backblaze B2 Sync + +on: + push: + branches: + - main + +jobs: + backblaze-cli-sync: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install b2 CLI tool + run: | + pip install b2 --log /dev/null + + - name: Sync all files that have a different size + run: | + b2 sync --compare-versions size --delete ./src/ "b2://ozoniusswebsite/" + + env: + B2_APPLICATION_KEY_ID: ${{ secrets.B2_APPLICATION_KEY_ID }} + B2_APPLICATION_KEY: ${{ secrets.B2_APPLICATION_KEY }} + Honeslty probably the real reason for which I've made this post is to test that the site is updated with this new page. +

+ +
+ + + + + + + diff --git a/src/blog/index.html b/src/blog/index.html index e77088a..3d0c7c2 100644 --- a/src/blog/index.html +++ b/src/blog/index.html @@ -41,6 +41,9 @@

Stories