act来跑github action

今天需要测试一下githubAction,在github上很方便,但是想本地跑一下githubaction 来看看是否可行。在github上找到了一个大牛的repo https://github.com/nektos/act?tab=readme-ov-file#installation-through-package-managers {95D82C7B-54AA-49E1-9F96-160C1C6512DA}.png 本地测试的命令

1
2
cd vyos-build-container-image 
 act -j build-and-push ./.github/workflows/vyos-build-container-image.yaml

{64AB45FA-CE69-420A-BEB3-26324C8FB8FB}.png 使用docker-desktop可以进行构建模拟

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
vyos-build-container-image on  main [!?] via 🐳 desktop-linux took 2m35s
 C:\ProgramData\chocolatey\lib\act-cli\tools\act.exe -P ubuntu-latest=huangxiaofenglogin/vyos-build:latest  -j build-and-push .\.github\workflows\vyos-build-container-image.yaml --privileged=true
time="2025-01-20T13:05:26+08:00" level=info msg="Using docker host 'npipe:////./pipe/docker_engine', and daemon socket 'npipe:////./pipe/docker_engine'"
time="2025-01-20T13:05:26+08:00" level=warning msg="--privileged is deprecated and will be removed soon, please switch to cli: `--container-options \"--privileged\"` or `.actrc`: `--container-options --privileged`."
[VyOS Build Container Image and Push to Docker Hub/build-and-push] 🚀  Start image=huangxiaofenglogin/vyos-build:latest
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker pull image=huangxiaofenglogin/vyos-build:latest platform= username= forcePull=true
[VyOS Build Container Image and Push to Docker Hub/build-and-push] using DockerAuthConfig authentication for docker pull
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker create image=huangxiaofenglogin/vyos-build:latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker run image=huangxiaofenglogin/vyos-build:latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker exec cmd=[node --no-warnings -e console.log(process.execPath)] user= workdir=
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     git clone 'https://github.com/docker/login-action' # ref=v3
[VyOS Build Container Image and Push to Docker Hub/build-and-push]  Run Main Checkout
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker cp src=D:\vyos-build-container-image\. dst=/mnt/d/vyos-build-container-image
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     Success - Main Checkout
[VyOS Build Container Image and Push to Docker Hub/build-and-push]  Run Main Download VyOS ISO
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker exec cmd=[bash -e /var/run/act/workflow/1] user= workdir=
| https://api.github.com/repositories/674742659/releases/latest
| {
|   "url": "https://api.github.com/repos/vyos/vyos-nightly-build/releases/195543324",
|   "assets_url": "https://api.github.com/repos/vyos/vyos-nightly-build/releases/195543324/assets",
|   "upload_url": "https://uploads.github.com/repos/vyos/vyos-nightly-build/releases/195543324/assets{?name,label}",
|   "html_url": "https://github.com/vyos/vyos-nightly-build/releases/tag/1.5-rolling-202501200007",
|   "id": 195543324,
|   "author": {
|     "login": "github-actions[bot]",
|     "id": 41898282,
|     "node_id": "MDM6Qm90NDE4OTgyODI=",
|     "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
|     "gravatar_id": "",
|     "url": "https://api.github.com/users/github-actions%5Bbot%5D",
|     "html_url": "https://github.com/apps/github-actions",
|     "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
|     "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
|     "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
|     "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
|     "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
|     "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
|     "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
|     "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
|     "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
|     "type": "Bot",
|     "user_view_type": "public",
|     "site_admin": false
|   },
|   "node_id": "RE_kwDOKDfBg84Lp8Ec",
|   "tag_name": "1.5-rolling-202501200007",
|   "target_commitish": "current",
|   "name": "1.5-rolling-202501200007",
|   "draft": false,
|   "prerelease": false,
|   "created_at": "2025-01-20T01:52:39Z",
|   "published_at": "2025-01-20T01:52:49Z",
|   "assets": [
|     {
|       "url": "https://api.github.com/repos/vyos/vyos-nightly-build/releases/assets/221721509",
|       "id": 221721509,
|       "node_id": "RA_kwDOKDfBg84NNzOl",
|       "name": "vyos-1.5-rolling-202501200007-generic-amd64.iso",
|       "label": "",
|       "uploader": {
|         "login": "github-actions[bot]",
|         "id": 41898282,
|         "node_id": "MDM6Qm90NDE4OTgyODI=",
|         "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
|         "gravatar_id": "",
|         "url": "https://api.github.com/users/github-actions%5Bbot%5D",
|         "html_url": "https://github.com/apps/github-actions",
|         "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
|         "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
|         "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
|         "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
|         "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
|         "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
|         "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
|         "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
|         "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
|         "type": "Bot",
|         "user_view_type": "public",
|         "site_admin": false
|       },
|       "content_type": "application/octet-stream",
|       "state": "uploaded",
|       "size": 553648128,
|       "download_count": 21,
|       "created_at": "2025-01-20T01:52:50Z",
|       "updated_at": "2025-01-20T01:53:01Z",
|       "browser_download_url": "https://github.com/vyos/vyos-nightly-build/releases/download/1.5-rolling-202501200007/vyos-1.5-rolling-202501200007-generic-amd64.iso"
|     },
|     {
|       "url": "https://api.github.com/repos/vyos/vyos-nightly-build/releases/assets/221721508",
|       "id": 221721508,
|       "node_id": "RA_kwDOKDfBg84NNzOk",
|       "name": "vyos-1.5-rolling-202501200007-generic-amd64.iso.minisig",
|       "label": "",
|       "uploader": {
|         "login": "github-actions[bot]",
|         "id": 41898282,
|         "node_id": "MDM6Qm90NDE4OTgyODI=",
|         "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
|         "gravatar_id": "",
|         "url": "https://api.github.com/users/github-actions%5Bbot%5D",
|         "html_url": "https://github.com/apps/github-actions",
|         "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
|         "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
|         "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
|         "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
|         "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
|         "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
|         "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
|         "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
|         "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
|         "type": "Bot",
|         "user_view_type": "public",
|         "site_admin": false
|       },
|       "content_type": "application/octet-stream",
|       "state": "uploaded",
|       "size": 342,
|       "download_count": 7,
|       "created_at": "2025-01-20T01:52:50Z",
|       "updated_at": "2025-01-20T01:52:50Z",
|       "browser_download_url": "https://github.com/vyos/vyos-nightly-build/releases/download/1.5-rolling-202501200007/vyos-1.5-rolling-202501200007-generic-amd64.iso.minisig"
|     }
|   ],
|   "tarball_url": "https://api.github.com/repos/vyos/vyos-nightly-build/tarball/1.5-rolling-202501200007",
|   "zipball_url": "https://api.github.com/repos/vyos/vyos-nightly-build/zipball/1.5-rolling-202501200007",
|   "body": "## vyos-1x\n- no changes\n## vyos-build\n- no changes\n"
| }
| https://github.com/vyos/vyos-nightly-build/releases/download/1.5-rolling-202501200007/vyos-1.5-rolling-202501200007-generic-amd64.iso
|   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
|                                  Dload  Upload   Total   Spent    Left  Speed
100  564M  100  564M    0     0  49.2M      0  0:00:11  0:00:11 --:--:-- 50.2M
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     Success - Main Download VyOS ISO
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     ::set-env:: tag_name=1.5-rolling-20250120
[VyOS Build Container Image and Push to Docker Hub/build-and-push]  Run Main Build Container Image
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker exec cmd=[bash -e /var/run/act/workflow/2] user= workdir=
| mount: /mnt/d/vyos-build-container-image/rootfs: WARNING: source write-protected, mounted read-only.
| Parallel unsquashfs: Using 6 processors
| 55738 inodes (61176 blocks) to write
|
|
|
| created 51764 files
| created 21941 directories
| created 3958 symlinks
| created 8 devices
| created 0 fifos
| created 4 sockets
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     Success - Main Build Container Image
[VyOS Build Container Image and Push to Docker Hub/build-and-push]  Run Main Login to Docker Hub
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker cp src=C:\Users\hxf16\.cache\act/docker-login-action@v3/ dst=/var/run/act/actions/docker-login-action@v3/
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker exec cmd=[/opt/acttoolcache/node/18.20.5/x64/bin/node /var/run/act/actions/docker-login-action@v3/dist/index.js] user= workdir=
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     ::error::Username and password required
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     Failure - Main Login to Docker Hub
[VyOS Build Container Image and Push to Docker Hub/build-and-push] exitcode '1': failure
[VyOS Build Container Image and Push to Docker Hub/build-and-push]  Run Post Login to Docker Hub
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   🐳  docker exec cmd=[/opt/acttoolcache/node/18.20.5/x64/bin/node /var/run/act/actions/docker-login-action@v3/dist/index.js] user= workdir=
[VyOS Build Container Image and Push to Docker Hub/build-and-push]   💬  ::debug::Exec.getExecOutput: docker logout
| [command]/usr/bin/docker logout
| Removing login credentials for https://index.docker.io/v1/
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     ::group::Post cache
| State not set
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     ::endgroup::
[VyOS Build Container Image and Push to Docker Hub/build-and-push]     Success - Post Login to Docker Hub
[VyOS Build Container Image and Push to Docker Hub/build-and-push] 🏁  Job failed
Error: Job 'build-and-push' failed

注意这个报错不是loop设备的报错,证明已经可行。 在wsl2执行会出现这个报错loop device not found吗, losetup: cannot find an unused loop device {911C1F1B-A416-415A-909B-5B1285577ACF}.png 参考这个url https://github.com/RPi-Distro/pi-gen/issues/257,找到了wsl2中docker无法创建loop设备。 这个地址 https://github.com/huangxiaofeng10047/docker_images的镜像是提供了act跑任务的基本镜像,上文中huangxiaofenglogin/vyos-build:latest 这个镜像是使用act-latest镜像添加依赖重新构建的。Dockerfile如下图所示

1
2
3
4
 cat .\Dockerfile
From catthehacker/ubuntu:act-latest
RUN apt-get update && apt-get install -y \
  squashfs-tools
Licensed under CC BY-NC-SA 4.0
最后更新于 Feb 25, 2025 00:42 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up