-
Notifications
You must be signed in to change notification settings - Fork 84
Set Up GitHub Actions Runner
- An Ubuntu server (e.g., Ubuntu 22.04)
- Sudo access to the server
- A GitHub repository (
https://github.com/hngprojects/hng_boilerplate_expressjs
)
First, SSH into your Ubuntu server:
ssh your_username@your_server_ip
Navigate to the /opt
directory and create a directory for the GitHub Actions runner:
sudo mkdir /opt/aiforhomework
cd /opt/aiforhomework
Download the latest version of the GitHub Actions runner:
curl -o actions-runner-linux-x64-2.303.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.303.0/actions-runner-linux-x64-2.303.0.tar.gz
Extract the downloaded archive:
sudo tar xzf actions-runner-linux-x64-2.303.0.tar.gz
Generate a token from your GitHub repository's settings:
- Go to your repository
https://github.com/hngprojects/hng_boilerplate_expressjs
. - Navigate to Settings > Actions > Runners.
- Click New self-hosted runner.
- Follow the instructions to generate a token.
Use the token to configure the runner:
./config.sh --url https://github.com/hngprojects/hng_boilerplate_expressjs --token YOUR_GENERATED_TOKEN
Install the necessary dependencies for the runner:
sudo apt-get install -y libicu66
Use the svc.sh
script to install and start the service:
sudo ./svc.sh install
sudo ./svc.sh start
Check the status of the runner to ensure it is running:
./svc.sh status
You should see output indicating that the service is active and running.
Navigate to your repository on GitHub and go to Settings > Actions > Runners. You should see your runner listed as Online
.
By following these steps, you have successfully set up a GitHub Actions runner for your repository hng_boilerplate_expressjs
on your Ubuntu server in the /opt/aiforhomework
directory. This runner is now ready to execute workflows for your repository.
To prevent direct pushes to the main
and dev
branches, set up branch protection rules:
-
Go to Your Repository Settings:
- Navigate to Settings > Branches.
-
Create a Branch Protection Rule:
- Click on Add rule.
- Under Branch name pattern, enter
main
(and repeat fordev
). - Enable Require pull request reviews before merging.
- Optionally, enable Include administrators to apply the rule to administrators as well.
- Save the changes.
This ensures that all changes to these branches must go through a pull request review process.