Skip to content

Commit c1c3557

Browse files
committed
GitHub Actionsのビルダーセットアップを更新し、プロキシモードに基づく新しいアクションを追加。通信ログを表示するレポート機能を実装。
1 parent 3cbfe3f commit c1c3557

File tree

6 files changed

+110
-3
lines changed

6 files changed

+110
-3
lines changed

.github/workflows/example-audit.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- name: Start buildcage builder
1212
id: buildcage
13-
uses: dash14/buildcage@main
13+
uses: dash14/buildcage/setup@main
1414
with:
1515
proxy_mode: audit
1616

@@ -35,3 +35,7 @@ jobs:
3535
context: /tmp/build-context
3636
push: false
3737
no-cache: true
38+
39+
- name: Show proxy report
40+
if: always()
41+
uses: dash14/buildcage/report@main

.github/workflows/example-restrict.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- name: Start buildcage builder
1212
id: buildcage
13-
uses: dash14/buildcage@main
13+
uses: dash14/buildcage/setup@main
1414
with:
1515
proxy_mode: restrict
1616
allowed_https_domains: registry.npmjs.org
@@ -36,3 +36,9 @@ jobs:
3636
context: /tmp/build-context
3737
push: false
3838
no-cache: true
39+
40+
- name: Show proxy report
41+
if: always()
42+
uses: dash14/buildcage/report@main
43+
with:
44+
fail_on_blocked: false

README.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,76 @@ Docker 標準の `--network=none` オプションはネットワークを完全
9292
| `HTTPS_PORTS` | `port1,port2,...` | `443` | HTTPSプロキシの待ち受けポート |
9393
| `EXTERNAL_RESOLVER` | `ip1 ip2 ...` | `8.8.8.8 8.8.4.4 valid=300s` | nginxの上流DNSリゾルバー |
9494

95+
## GitHub Actions での使い方
96+
97+
### セットアップ
98+
99+
```yaml
100+
- name: Start buildcage builder
101+
id: buildcage
102+
uses: dash14/buildcage/setup@main
103+
with:
104+
proxy_mode: restrict
105+
allowed_https_domains: registry.npmjs.org
106+
```
107+
108+
| パラメータ | 必須 | デフォルト | 説明 |
109+
|-----------|------|-----------|------|
110+
| `buildcage_version` | No | `latest` | GHCRイメージタグ |
111+
| `proxy_mode` | No | `restrict` | 動作モード (`audit` / `restrict`) |
112+
| `allowed_http_domains` | No | 空文字 | HTTP許可ドメイン(カンマ区切り) |
113+
| `allowed_https_domains` | No | 空文字 | HTTPS許可ドメイン(カンマ区切り) |
114+
115+
**Output:**
116+
117+
| 名前 | 説明 |
118+
|------|------|
119+
| `endpoint` | `docker buildx create --driver remote` に渡すBuildKitエンドポイント |
120+
121+
### レポート
122+
123+
ビルド後に通信ログを表示し、BLOCKED があれば失敗させます:
124+
125+
```yaml
126+
- name: Show proxy report
127+
uses: dash14/buildcage/report@main
128+
```
129+
130+
| パラメータ | 必須 | デフォルト | 説明 |
131+
|-----------|------|-----------|------|
132+
| `fail_on_blocked` | No | `true` | BLOCKEDな通信が検出された場合にステップを失敗させる |
133+
134+
### 完全な例
135+
136+
```yaml
137+
jobs:
138+
build:
139+
runs-on: ubuntu-latest
140+
steps:
141+
- name: Start buildcage builder
142+
id: buildcage
143+
uses: dash14/buildcage/setup@main
144+
with:
145+
proxy_mode: restrict
146+
allowed_https_domains: registry.npmjs.org
147+
148+
- name: Set up Docker Buildx
149+
uses: docker/setup-buildx-action@v3
150+
with:
151+
driver: remote
152+
endpoint: ${{ steps.buildcage.outputs.endpoint }}
153+
154+
- name: Build
155+
uses: docker/build-push-action@v6
156+
with:
157+
context: .
158+
push: false
159+
no-cache: true
160+
161+
- name: Show proxy report
162+
uses: dash14/buildcage/report@main
163+
```
164+
95165
## 開発
96166

97167
### 前提条件
@@ -168,8 +238,12 @@ docker compose logs -f builder
168238

169239
```
170240
.
241+
├── setup/
242+
│ ├── action.yml # GitHub Action: dash14/buildcage/setup@main
243+
│ └── compose.action.yml # GitHub Actions用Compose設定(imageタグ付き)
244+
├── report/
245+
│ └── action.yml # GitHub Action: dash14/buildcage/report@main
171246
├── compose.yml # Docker Compose設定
172-
├── compose.action.yml # GitHub Actions用Compose設定(imageタグ付き)
173247
├── compose.test.yml # テスト用オーバーライド設定
174248
├── Makefile # 操作用コマンド集
175249
├── show-log.sh # ログ解析スクリプト

report/action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Report
2+
description: Show proxy communication logs and fail if blocked connections detected
3+
4+
inputs:
5+
fail_on_blocked:
6+
description: "Fail the step if blocked connections are detected"
7+
required: false
8+
default: 'true'
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Show proxy report
14+
shell: bash
15+
env:
16+
COMPOSE_FILE: ${{ github.action_path }}/../setup/compose.action.yml
17+
FAIL_ON_BLOCKED: ${{ inputs.fail_on_blocked }}
18+
run: |
19+
"${{ github.action_path }}/../show-log.sh" || {
20+
if [ "$FAIL_ON_BLOCKED" = "true" ]; then
21+
exit 1
22+
fi
23+
}
File renamed without changes.

0 commit comments

Comments
 (0)