|
1 | 1 | --- |
2 | | -title: Install and Set Up GitHub Self-Hosted Runner on Google Cloud C4A Virtual Machine |
| 2 | +title: Set up a GitHub Self-Hosted Runner |
3 | 3 | weight: 4 |
4 | 4 |
|
5 | 5 | ### FIXED, DO NOT MODIFY |
6 | 6 | layout: learningpathall |
7 | 7 | --- |
8 | 8 |
|
9 | 9 |
|
10 | | -## Set Up GitHub Actions Self-Hosted Runner on Google Axion C4A Virtual Machine |
| 10 | +This section shows how to deploy a self-hosted GitHub Actions runner on your instance. It covers installing Git and GitHub CLI, authenticating with GitHub and configuring the runner on an Arm64 environment for optimized CI/CD workflows. |
11 | 11 |
|
12 | | -This Learning Path shows how to deploy a self-hosted GitHub Actions runner on a Google Cloud C4A Arm64 virtual machine running Ubuntu. It covers installing Git and GitHub CLI, authenticating with GitHub and configuring the runner on an Arm64 environment for optimized CI/CD workflows. |
| 12 | +### Set up development environment |
| 13 | + |
| 14 | +Start by installing the required dependencies using the `apt` package manager: |
13 | 15 |
|
14 | | -### Install Git and GitHub CLI |
15 | 16 | ```console |
16 | | -sudo apt update |
17 | | -sudo apt install -y git gh |
| 17 | +sudo apt update |
| 18 | +sudo apt install -y git gh vim |
| 19 | +``` |
| 20 | + |
| 21 | +Next step is to configure your git credentials. Update the command with your name and email. |
| 22 | + |
| 23 | +```bash |
| 24 | +git config --global user.email "you@example.com" |
| 25 | +git config --global user.name "Your Name" |
18 | 26 | ``` |
19 | | -Login to GitHub |
| 27 | + |
| 28 | +Now you are ready to connect the machine to GitHub. The command below is used to authenticate the GitHub CLI with your GitHub account. It allows you to securely log in using a web browser or token, enabling the CLI to interact with repositories, actions, and other GitHub features on your behalf. |
| 29 | + |
| 30 | + |
20 | 31 | ```console |
21 | | -gh auth login |
22 | | - ``` |
23 | | -The command `gh auth login` is used to authenticate the GitHub CLI with your GitHub account. It allows you to securely log in using a web browser or token, enabling the CLI to interact with repositories, actions, and other GitHub features on your behalf. |
| 32 | +gh auth login |
| 33 | +``` |
| 34 | + |
| 35 | +The command will prompt you to make a few choices. For this use-case, you can use the default ones as shown in the image below. |
24 | 36 |
|
25 | 37 |  |
26 | 38 |
|
27 | | -Below is the GitHub login UI: |
| 39 | +{{% notice %}} |
| 40 | +If you get an error opening the browser on your virtual machine, you can navigate to the following URL on the host machine. |
| 41 | +``` |
| 42 | +https://github.com/login/device |
| 43 | +``` |
| 44 | +From there, you can enter the code displayed in the CLI of the virtual machine. |
| 45 | +{{% /notice %}} |
| 46 | + |
| 47 | +If the log in was successful, you will see the following confirmation in your browser window. |
28 | 48 |
|
29 | 49 |  |
30 | 50 |
|
31 | | -### Test GitHub CLI and Git |
32 | | -Create a test repo: |
| 51 | +### Test GitHub CLI and Git |
| 52 | + |
| 53 | +The command below creates a new public GitHub repository named **test-repo** using the GitHub CLI. It sets the repository visibility to public, meaning anyone can view it |
| 54 | + |
33 | 55 | ```console |
34 | | -gh repo create test-repo –public |
| 56 | +gh repo create test-repo --public |
35 | 57 | ``` |
36 | 58 | You should see an output similar to: |
37 | 59 | ```output |
38 | 60 | ✓ Created repository <your-github-account>/test-repo on GitHub |
39 | 61 | https://github.com/<your-github-account>/test-repo |
40 | 62 | ``` |
41 | 63 |
|
42 | | -The command `gh repo create test-repo --public` creates a new public GitHub repository named **test-repo** using the GitHub CLI. It sets the repository visibility to public, meaning anyone can view it |
43 | 64 |
|
44 | 65 | ### Configure the Self-Hosted Runner |
45 | | -Go to your repository's **Settings > Actions**, and under the **Runners** section, click on **Add Runner** or view existing self-hosted runners. |
| 66 | + |
| 67 | +* Go to your repository's **Settings > Actions**, and under the **Runners** section |
| 68 | +* Click on **Add Runner** or view existing self-hosted runners. |
| 69 | + |
| 70 | +{{% notice Note %}} |
46 | 71 | If the **Actions** tab is not visible, ensure Actions are enabled by navigating to **Settings > Actions > General**, and select **Allow all actions and reusable workflows**. |
| 72 | +{{% /notice %}} |
47 | 73 |
|
48 | 74 |  |
49 | 75 |
|
50 | | -Then, click on the **New runner** button, followed by **New self-hosted runner**. In the **Add new self-hosted runner** section, proceed as follows: |
51 | | -- Select Linux for the operating system. |
52 | | -- Choose ARM64 for the architecture |
| 76 | +Then, click on the **New self-hosted runner** button. In the **Add new self-hosted runner** section. Select Linux for the operating system, and choose ARM64 for the architecture. This will generate commands to set up the runner. Copy and run them on your Google Axion C4A virtual machine. |
53 | 77 |
|
54 | 78 |  |
55 | 79 |
|
56 | | -Next, execute the following instructions on your Google Axion C4A virtual machine: |
57 | | -```console |
58 | | -mkdir actions-runner && cd actions-runner# Download the latest runner package |
59 | | -curl -o actions-runner-linux-arm64-2.326.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.326.0/actions-runner-linux-arm64-2.326.0.tar.gz |
60 | | -echo "ee7c229c979c5152e9f12be16ee9e83ff74c9d9b95c3c1aeb2e9b6d07157ec85 actions-runner-linux-arm64-2.326.0.tar.gz" | shasum -a 256 -c# Extract the installer |
61 | | -tar xzf ./actions-runner-linux-arm64-2.326.0.tar.gz |
62 | | -``` |
63 | | -Then, configure the virtual machine with the following command: |
64 | | - |
65 | | -```console |
66 | | -./config.sh --url https://github.com/<YOUR_USERNAME>/YOUR_REPO --token YOUR_TOKEN |
67 | | -``` |
68 | | -Replace `YOUR_USERNAME`, `YOUR_REPO`, and `YOUR_TOKEN` accordingly. |
69 | | -This command links the runner to your GitHub repo using a one-time registration token. |
| 80 | +The final command links the runner to your GitHub repo using a one-time registration token. |
70 | 81 |
|
71 | 82 | During the command’s execution, you will be prompted to provide the runner group, the name of the runner, and the work folder name. You can accept the defaults by pressing **Enter** at each step. The output will resemble as below: |
72 | 83 |
|
73 | | -You should see an output similar to: |
74 | | - |
75 | 84 | ```output |
76 | 85 | -------------------------------------------------------------------------------- |
77 | 86 | | ____ _ _ _ _ _ _ _ _ | |
@@ -111,3 +120,5 @@ Current runner version: '2.326.0' |
111 | 120 | The runner will now be visible in the GitHub actions: |
112 | 121 |
|
113 | 122 |  |
| 123 | + |
| 124 | +For now, you can terminate the `./run.sh` command with `Ctrl+C`. Move on to the next section to set up a simple web server using the runner. |
0 commit comments