Skip to content

Commit c02f7e4

Browse files
committed
...
1 parent 5c09533 commit c02f7e4

File tree

5 files changed

+160
-101
lines changed

5 files changed

+160
-101
lines changed

misc/content/2020/09/tips-on-github-actions/tips-on-github-actions.md

Lines changed: 12 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Slug: tips-on-github-actions
55
Title: Tips on GitHub Actions
66
Category: Computer Science
77
Tags: Computer Science, GitHub Actions, CICD
8-
Modified: 2025-11-21 09:23:02
8+
Modified: 2025-11-23 11:53:18
99

1010
**Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!**
1111

@@ -38,26 +38,8 @@ Modified: 2025-11-21 09:23:02
3838
but this doesn't give you much priviledge
3939
as the root account in a GitHub Actions VM is restricted too.
4040

41-
4. The `runner` account (even with `sudo`) in GitHub Actions VMs
42-
have restricted priviledges.
43-
For example,
44-
the Linux perf (and equivalent) tools cannot be run in GitHub Actions VMs
45-
even if `sudo` is used.
46-
Docker containers running in GitHub Actions VMs are restricted too.
47-
For more details,
48-
please refer to
49-
[Supported Linux capabilities](https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#supported-linux-capabilities)
50-
.
51-
5241
3. OS: ubuntu-latest, windows-latest, macOS-latest
5342

54-
4. Docker container is available in Ubuntu and Windows but not macOS in GitHub Actions due to license issues.
55-
To use Docker in macOS in GitHub Actions,
56-
you have to install it manually.
57-
Please refer to
58-
[Is it possible to install and configure Docker on MacOS runner?](https://github.community/t/is-it-possible-to-install-and-configure-docker-on-macos-runner/16981)
59-
for more details.
60-
6143
5. Good practices for GitHub repository with GitHub Actions workflows:
6244
- Have 2 protected branches `main` and `dev`,
6345
where `main` is reserved for releasing
@@ -66,20 +48,6 @@ Modified: 2025-11-21 09:23:02
6648
- A PR from `dev` to `main` should be made
6749
when it is ready to release a new version.
6850

69-
## Issues and Solutions
70-
71-
### Error: The process '/usr/bin/git' failed with exit code 1
72-
73-
Sympton: A GitHub Actions workflow fail to checkout a branch of a repository
74-
and throws the following error message.
75-
76-
> Error: The process '/usr/bin/git' failed with exit code 1
77-
78-
Possible Causes and Solutions: It's possible that you use a branch name
79-
(e.g., used `main` while the repo does not have a `main` branch) which does not exist.
80-
If so,
81-
use the correct branch name might fix the issue.
82-
8351
## Branch Matching
8452

8553
on:
@@ -97,23 +65,6 @@ and
9765
[Workflow syntax for GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions)
9866
.
9967

100-
101-
## PowerShell on Windows
102-
103-
### Set PATH
104-
105-
echo "::add-path::./swigwin-4.0.1"
106-
107-
echo %programfiles%
108-
echo ::set-env name=ProgramFilesPath::%programfiles%
109-
110-
https://stackoverflow.com/questions/60169752/how-to-update-the-path-in-a-github-action-workflow-file-for-a-windows-latest-hos
111-
112-
https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
113-
114-
Prepends a directory to the system PATH variable for all subsequent actions in the current job. The currently running action cannot access the new path variable.
115-
116-
11768
## Good Github Actions
11869

11970
### checkout
@@ -152,64 +103,24 @@ https://github.com/peter-evans/create-pull-request
152103

153104
[Introducing GitHub Package Registry](https://www.youtube.com/watch?v=N_-Cu9_2YAA)
154105

155-
#### Examples of Using Docker Containers
156-
157-
- [fun-poker-game/poker-rs - profiling.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/profiling.yml)
158-
159-
- [fun-poker-game/poker-rs - pre-release_centos7.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/pre-release_centos7.yml)
160-
161-
- [fun-poker-game/poker-rs - on_merge.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/on_merge.yml)
162-
163-
- [fun-poker-game/poker-rs - lint.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/lint.yml)
164-
165-
- [fun-poker-game/poker-rs - bench_on_pr.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/bench_on_pr.yml)
166-
167-
- [legendu-net/aiutil - lint.yml](https://github.com/legendu-net/aiutil/blob/dev/.github/workflows/lint.yml)
168-
169-
## Self-hosted Runners
170-
171-
1. straight forward to set up self-hosted runners following instructions
172-
173-
2. No need for the machine to be publicly accessible
174-
175-
3. Currently,
176-
a runner can be configured to accept only 1 repo in a personal account
177-
(which is inconveneint)
178-
or multiple repositories in a GitHub organization.
179-
180-
4. A self-hosted runner is able to use SSH keys on the host.
181-
However,
182-
if a Docker container is used with a self-hosted runner,
183-
you have to properly expose SSH keys on the host to the Docker container.
184-
A feasible way is to
185-
186-
1. Configure the GitHub Action workflow to mount `$HOME/.ssh` to `/ssh`.
187-
2. Copy `/ssh` to `/root/.ssh` in the Docker container.
188-
3. Run `chmod 600 /root/.ssh/*` to ensure right permissions of SSH keys and configuration files.
189-
190-
### Idle Organization Runners Which Don't Pick up Jobs
191-
192-
![](https://github.com/user-attachments/assets/5b494a23-7ecd-40da-8d1f-47d373d14c3c)
193-
194-
![](https://github.com/user-attachments/assets/5b494a23-7ecd-40da-8d1f-47d373d14c3c)
106+
## References
195107

196-
https://github.com/orgs/community/discussions/26823
197-
Self-hosted runner registered as idle but not picking up jobs #26823
108+
- [Common Issues and Solutions for GitHub Actions]( https://www.legendu.net/misc/blog/common-issues-and-solutions-for-github-actions )
198109

199-
https://github.com/orgs/community/discussions/120813
200-
Self-hosted runners is idle but not picking up jobs #120813
110+
- [Self-hosted Runners for GitHub Actions]( https://www.legendu.net/misc/blog/self-hosted-runners-for-github-actions )
201111

112+
- [Use Docker Containers for GitHub Actions]( https://www.legendu.net/misc/blog/use-docker-containers-for-github-actions )
202113

203-
## References
114+
- [Machine learning operations with GitHub Actions and Kubernetes - GitHub Universe 2019](https://www.youtube.com/watch?v=Ll50l3fsoYs&feature=emb_logo)
204115

205-
https://www.youtube.com/watch?v=Ll50l3fsoYs&feature=emb_logo
116+
- [Advanced GitHub Actions: workflows for production grade CI/CD - GitHub Universe 2019](https://www.youtube.com/watch?v=0ahRkhrOePo)
206117

207-
https://www.youtube.com/watch?v=0ahRkhrOePo
118+
- [Virtual Environments for Github Hosted Runners](https://docs.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#about-virtual-environments)
208119

209-
https://docs.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#about-virtual-environments
120+
- [Github Actions Workflow Error Permission Denied](https://stackoverflow.com/questions/57830375/github-actions-workflow-error-permission-denied)
210121

211-
https://stackoverflow.com/questions/57830375/github-actions-workflow-error-permission-denied
122+
- [GitHub’s Actions v2 — Tips and Tricks](https://medium.com/inexdigital-fr/githubs-actions-v2-tips-and-tricks-c083ec6cfae0)
212123

213-
[GitHub’s Actions v2 — Tips and Tricks](https://medium.com/inexdigital-fr/githubs-actions-v2-tips-and-tricks-c083ec6cfae0)
124+
- [Questions about PR workflows and actions/checkout@v2](https://github.community/t/questions-about-pr-workflows-and-actions-checkout-v2/122347)
214125

215-
[Questions about PR workflows and actions/checkout@v2](https://github.community/t/questions-about-pr-workflows-and-actions-checkout-v2/122347)
126+
- [Powershell on Windows for GitHub Actions]( https://www.legendu.net/misc/blog/powershell-on-windows-for-github-actions )
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Status: published
2+
Date: 2025-11-23 11:04:17
3+
Modified: 2025-11-23 11:04:17
4+
Author: Benjamin Du
5+
Slug: common-issues-and-solutions-for-github-actions
6+
Title: Common Issues and Solutions for GitHub Actions
7+
Category: Computer Science
8+
Tags: Computer Science, programming, GitHub Actions, CICD, development, issues, solutions
9+
10+
**Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!**
11+
12+
## Error: No space left.
13+
Symptom: A GitHub Actions workflow fails with the error message "No space left".
14+
15+
Possible Solutions:
16+
1. An Azure VM mounts an (ephemeral) disk to `/mnt`
17+
which is big enough for most CICD pipelines.
18+
You can leverage `/mnt` to store outputs of your CICD pipelines when necessary.
19+
[legendu-net/docker_image_builder - config_docker.py](https://github.com/legendu-net/docker_image_builder/blob/dev/config_docker.py)
20+
is such an example which stores built Docker images into `/mnt/docker`.
21+
22+
2. Remove non needed tools.
23+
Please refer to
24+
[apache/flink - free_disk_space.sh](https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh)
25+
and
26+
[legendu-net/docker-base - purge_cache.sh](https://github.com/legendu-net/docker-base/blob/dev/scripts/sys/purge_cache.sh)
27+
for examples.
28+
29+
## Error: The process '/usr/bin/git' failed with exit code 1
30+
31+
Symptom: A GitHub Actions workflow fail to checkout a branch of a repository
32+
and throws the following error message.
33+
34+
> Error: The process '/usr/bin/git' failed with exit code 1
35+
36+
Possible Causes and Solutions: It's possible that you use a branch name
37+
(e.g., used `main` while the repo does not have a `main` branch) which does not exist.
38+
If so,
39+
use the correct branch name might fix the issue.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Status: published
2+
Date: 2025-11-23 11:06:12
3+
Modified: 2025-11-23 11:06:12
4+
Author: Benjamin Du
5+
Slug: powershell-on-windows-for-github-actions
6+
Title: Powershell on Windows for GitHub Actions
7+
Category: Computer Science
8+
Tags: Computer Science, programming, GitHub Actions, CICD, development, Windows, PowerShell
9+
10+
**Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!**
11+
12+
## PowerShell on Windows
13+
14+
### Set PATH
15+
16+
echo "::add-path::./swigwin-4.0.1"
17+
18+
echo %programfiles%
19+
echo ::set-env name=ProgramFilesPath::%programfiles%
20+
21+
https://stackoverflow.com/questions/60169752/how-to-update-the-path-in-a-github-action-workflow-file-for-a-windows-latest-hos
22+
23+
https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
24+
25+
Prepends a directory to the system PATH variable for all subsequent actions in the current job. The currently running action cannot access the new path variable.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Status: published
2+
Date: 2025-11-23 10:49:01
3+
Modified: 2025-11-23 10:49:01
4+
Author: Benjamin Du
5+
Slug: self-hosted-runners-for-github-actions
6+
Title: Self-hosted Runners for GitHub Actions
7+
Category: Computer Science
8+
Tags: Computer Science, programming, GitHub Actions, CICD, development, self-hosted, runner
9+
10+
**Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!**
11+
12+
1. straight forward to set up self-hosted runners following instructions
13+
14+
2. No need for the machine to be publicly accessible
15+
16+
3. Currently,
17+
a runner can be configured to accept only 1 repo in a personal account
18+
(which is inconveneint)
19+
or multiple repositories in a GitHub organization.
20+
21+
4. A self-hosted runner is able to use SSH keys on the host.
22+
However,
23+
if a Docker container is used with a self-hosted runner,
24+
you have to properly expose SSH keys on the host to the Docker container.
25+
A feasible way is to
26+
27+
1. Configure the GitHub Action workflow to mount `$HOME/.ssh` to `/ssh`.
28+
2. Copy `/ssh` to `/root/.ssh` in the Docker container.
29+
3. Run `chmod 600 /root/.ssh/*` to ensure right permissions of SSH keys and configuration files.
30+
31+
## Idle Organization Runners Which Don't Pick up Jobs
32+
33+
![](https://github.com/user-attachments/assets/5b494a23-7ecd-40da-8d1f-47d373d14c3c)
34+
35+
![](https://github.com/user-attachments/assets/5b494a23-7ecd-40da-8d1f-47d373d14c3c)
36+
37+
[Self-hosted runner registered as idle but not picking up jobs #26823](https://github.com/orgs/community/discussions/26823)
38+
39+
[Self-hosted runners is idle but not picking up jobs #120813](https://github.com/orgs/community/discussions/120813)
40+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Status: published
2+
Date: 2025-11-23 10:57:08
3+
Modified: 2025-11-23 10:57:08
4+
Author: Benjamin Du
5+
Slug: use-docker-containers-for-github-actions
6+
Title: Use Docker Containers for GitHub Actions
7+
Category: Computer Science
8+
Tags: Computer Science, programming, GitHub Actions, CICD, development, Docker, container
9+
10+
**Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!**
11+
12+
## Tips & Traps
13+
14+
1. Docker container is available in Ubuntu and Windows but not macOS in GitHub Actions due to license issues.
15+
To use Docker in macOS in GitHub Actions,
16+
you have to install it manually.
17+
Please refer to
18+
[Is it possible to install and configure Docker on MacOS runner?](https://github.community/t/is-it-possible-to-install-and-configure-docker-on-macos-runner/16981)
19+
for more details.
20+
21+
2. The `runner` account (even with `sudo`) in GitHub Actions VMs
22+
have restricted priviledges.
23+
For example,
24+
the Linux perf (and equivalent) tools cannot be run in GitHub Actions VMs
25+
even if `sudo` is used.
26+
Docker containers running in GitHub Actions VMs are restricted too.
27+
For more details,
28+
please refer to
29+
[Supported Linux capabilities](https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#supported-linux-capabilities)
30+
.
31+
32+
## Examples
33+
34+
- [fun-poker-game/poker-rs - profiling.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/profiling.yml)
35+
36+
- [fun-poker-game/poker-rs - pre-release_centos7.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/pre-release_centos7.yml)
37+
38+
- [fun-poker-game/poker-rs - on_merge.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/on_merge.yml)
39+
40+
- [fun-poker-game/poker-rs - lint.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/lint.yml)
41+
42+
- [fun-poker-game/poker-rs - bench_on_pr.yml](https://github.com/fun-poker-game/poker-rs/blob/dev/.github/workflows/bench_on_pr.yml)
43+
44+
- [legendu-net/aiutil - lint.yml](https://github.com/legendu-net/aiutil/blob/dev/.github/workflows/lint.yml)

0 commit comments

Comments
 (0)