Compare commits

...

2 Commits

Author SHA1 Message Date
8e96e0b315 Fixed bug with images
All checks were successful
Generate and upload hugo website / generate_and_uplaod_site (push) Successful in 1m27s
2025-02-20 06:32:02 +01:00
30aa956a5b Fixed bug with images 2025-02-20 06:30:26 +01:00

View File

@ -1,6 +1,6 @@
--- ---
date: 2025-02-17T21:16:00+01:00 date: 2025-02-17T21:16:00+01:00
draft: false draft: true
title: Automating my website using the Gitea act runner title: Automating my website using the Gitea act runner
--- ---
Currently, when I make a change or add content to my web page after committing my changes to Gitea, I need to manually build the web page using the hugo command and then copy the files to my web host. This process can be automated using the Gitea act runner! Currently, when I make a change or add content to my web page after committing my changes to Gitea, I need to manually build the web page using the hugo command and then copy the files to my web host. This process can be automated using the Gitea act runner!
@ -69,11 +69,11 @@ container:
Using this docker compose file and config the Gitea server and runner are started and are able to connect! Using this docker compose file and config the Gitea server and runner are started and are able to connect!
![[runner_status.png]] ![The runner is connected!](images/runner_status.png)
The test job supplied by Gitea is run and is successful! The test job supplied by Gitea is run and is successful!
![[job_success.png]] ![The test job also works!](images/job_success.png)
## Configuring the workflow ## Configuring the workflow
@ -119,7 +119,7 @@ jobs:
Firstly go is installed and then the Hugo application is compiled with go. Next the ssh keys, The private key for the container and the public key for the server, are copied into place to allow the generated website to be installed on the targeted server. These keys are configured in Gitea in the action secrets Firstly go is installed and then the Hugo application is compiled with go. Next the ssh keys, The private key for the container and the public key for the server, are copied into place to allow the generated website to be installed on the targeted server. These keys are configured in Gitea in the action secrets
![[runner_secrets.png]] ![Configuring the runner secrets](images/runner_secrets.png)
However before this can work some work needs to be done on the server hosting the website. The runner needs a user that has the correct permissions to edit the web server files and that user needs to have the correct shh keys. Because I'm into automating as much as I can in my home lab I naturally edited my Ansible role for Gitea to make these changed for me. Below is my role for Gitea: However before this can work some work needs to be done on the server hosting the website. The runner needs a user that has the correct permissions to edit the web server files and that user needs to have the correct shh keys. Because I'm into automating as much as I can in my home lab I naturally edited my Ansible role for Gitea to make these changed for me. Below is my role for Gitea:
@ -181,10 +181,10 @@ Unfortunately I can't thing if an eloquent way of automating the creation of the
The private key in the file `runner_key` is copied to the Gitea secrets, the public key is added to the variables section of the Ansible playbook. And finally the public ssh key of the server `/etc/ssh/ssh_host_rsa_key.pub` is added to the secrets as the fingerprint. In this case I logged into the server running my web server and copied the keys from there. The private key in the file `runner_key` is copied to the Gitea secrets, the public key is added to the variables section of the Ansible playbook. And finally the public ssh key of the server `/etc/ssh/ssh_host_rsa_key.pub` is added to the secrets as the fingerprint. In this case I logged into the server running my web server and copied the keys from there.
![[the_workflow_works.png]] ![The workflow is working!](images/the_workflow_works.png)
After creating some content on my website and pushing the changes I'm able to see my new test post! After creating some content on my website and pushing the changes I'm able to see my new test post!
![[my_post.png]] ![My post has been uploaded!](images/my_post.png)
There are definitely things to improve here. The runner container could use a purpose made image to run the container with Hugo already built. This would speed up the time it takes for the action to be run. However, this is my first real use of any CI/CD pipelines and I'm happy with the end result! There are definitely things to improve here. The runner container could use a purpose made image to run the container with Hugo already built. This would speed up the time it takes for the action to be run. However, this is my first real use of any CI/CD pipelines and I'm happy with the end result!