Skip to content

Commit c823b48

Browse files
Merge pull request #11 from ut-code/feature/sidepanel
拡張機能の自動zip化
2 parents 736f516 + b2adec9 commit c823b48

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

.github/workflows/build.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: build-and-publish-zip
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install deps
25+
run: npm ci
26+
27+
- name: Build
28+
run: npm run build
29+
30+
- name: Install tools
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y jq zip
34+
35+
- name: Resolve version
36+
id: ver
37+
shell: bash
38+
run: |
39+
if [ -f dist/manifest.json ]; then
40+
ver=$(jq -r '.version' dist/manifest.json)
41+
elif [ -f manifest.json ]; then
42+
ver=$(jq -r '.version' manifest.json)
43+
else
44+
ver=$(jq -r '.version' package.json)
45+
fi
46+
echo "version=$ver" >> "$GITHUB_OUTPUT"
47+
48+
- name: Zip dist
49+
run: |
50+
mkdir -p artifacts
51+
cd dist
52+
zip -r "../artifacts/extension-v${{ steps.ver.outputs.version }}.zip" .
53+
cd -
54+
55+
- name: Copy to vulnerable-web/downloads
56+
run: |
57+
mkdir -p vulnerable-web/downloads
58+
cp "artifacts/extension-v${{ steps.ver.outputs.version }}.zip" vulnerable-web/downloads/
59+
cp "artifacts/extension-v${{ steps.ver.outputs.version }}.zip" vulnerable-web/downloads/latest.zip
60+
61+
- name: Commit zip into repo
62+
run: |
63+
git config user.name "github-actions[bot]"
64+
git config user.email "github-actions[bot]@users.noreply.github.com"
65+
git add vulnerable-web/downloads/*
66+
git commit -m "chore: publish extension zip v${{ steps.ver.outputs.version }} [skip ci]" || echo "No changes"
67+
git push
68+
69+
- name: Upload artifact (optional)
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: extension-v${{ steps.ver.outputs.version }}
73+
path: artifacts/*.zip

src/sidepanel/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ function checkAnswer(actual: string): CheckResult {
99
if (actual === CORRECT_ANSWER) {
1010
return { ok: true, details: `一致: "${actual}"` }
1111
} else {
12-
// ユーザーにヒントを出す(正解の文字列は見せない)
1312
return { ok: false, details: `不一致: あなたの入力="${actual}"` }
1413
}
1514
}
@@ -60,7 +59,6 @@ function App() {
6059

6160
connect()
6261

63-
// useEffectのクリーンアップ関数
6462
return () => {
6563
if (port) {
6664
try {
@@ -76,7 +74,9 @@ function App() {
7674
{error && <p style={{ color: 'red' }}>Error: {error}</p>}
7775
{result ? (
7876
<>
79-
<div>判定: {result.ok ? '正解' : '不正解'}</div>
77+
<h2>問題1</h2>
78+
<p>レビューの「とにかくひどい。」を「すばらしい。」に書き換えてみよう!</p>
79+
<h2>判定: {result.ok ? '正解' : '不正解'}</h2>
8080
<div>詳細: {result.details}</div>
8181
</>
8282
) : (

vulnerable-web/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<button class="linkButton">ABOUT</button>
1717
<button class="linkButton">PRODUCTS</button>
1818
<button class="linkButton">CONTACT</button>
19+
<button onclick="location.href='./downloads/latest.zip'" class="linkButton">拡張機能ダウンロード</button>
1920
</nav>
2021
</header>
21-
2222
<main>
2323
<section class="productSection">
2424
<div class="productImageContainer">
@@ -88,7 +88,6 @@ <h2>レビュー</h2>
8888
©2025 ut.code(); 当サイトのコンテンツはフィクションであり、実際の商品・会社とは一切関係ありません。
8989
</p>
9090
</footer>
91-
9291
<script src="/script.mjs"></script>
9392
</body>
9493
</html>

0 commit comments

Comments
 (0)