We have a few custom services running on our services, custom in the sense that they are programmed from scratch and continually developed. This deployment-system allows us to test, ship new code, and restart the service automatically.
Our deployment-system is a set of custom bash-scripts which run on our server and are triggered from github, where we store our code.
The deployment is triggered at the end of a successfully run testing chain which is built with github actions.
Step by Step: How to deploy a new service
In order to explain the deployment chain we will bring forth all the steps needed to deploy a new service with this system.
your sourcecode has its own repository within our github organization.
the repository is public
the repository has access to our self-hosted action runner.
(please ask an organization-owner to grant this access)
I. Creating a github workflow
In your repository go to tab Actions and setup the Deploy to Angrezi Servers workflow.
Click "Set up this workflow" and commit the new file
You dont need to change anything here but can add further steps to this workflow for example to build and test your application.
Have a look at other angrezi-services to better understand
how we use github actions.
II. Setting up the .environment folder
Our deployment expects a .environment folder to be present in the root folder of your repository.
This folder contains all files which are bound to angrezis server environment.
Usually systemd-service files, other configuration and a deploy script are situated here.
III. Creating a Deploy-script
Create a file ./environment/deploy.sh
This file well be automatically called at the end of a successful github-action workflow.
You have access to a few environment variables in your script:
# accessible var DEPLOY_DEST
# accessible var DEPLOY_FROM
IV. Setting up the service on angrezi-server
Log in to server.radioangrezi.de and run sudo setup-service [service-name] .
this will copy all the environment-files into /opt/services/[service-name] and symlink a few known configuration files automatically.
.service will be linked and enabled as a systemd service.
.monit-conf will be linked as a monit config file.
You have to link all other configuration files manually.
Each time you make changes to files in .environment/ you have to call setup-service again for your changes to take effect.
This is a security measure.