From c04fcb68e5ae47b95cee390b0e7d3eae63f4e8aa Mon Sep 17 00:00:00 2001 From: 5509 Date: Wed, 6 Aug 2025 08:42:25 +0900 Subject: [PATCH 1/3] build for cf --- .gitignore | 3 ++- package.json | 3 ++- wrangler.jsonc | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 wrangler.jsonc diff --git a/.gitignore b/.gitignore index 86e1299..c008be3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ playwright-report/ test-results/ -node_modules/ \ No newline at end of file +node_modules/ +dist/ \ No newline at end of file diff --git a/package.json b/package.json index b11bfec..059e960 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "test:ui": "node_modules/.bin/playwright test --ui", "test:debug": "node_modules/.bin/playwright test --debug", "serve": "npx http-server public -p 3000", - "install-playwright": "npx playwright install" + "install-playwright": "npx playwright install", + "build-for-cf": "mkdir -p dist && cp -r public/* dist/ && cp -r playwright-report/index.html dist/playwright-report.html" }, "keywords": [ "playwright", diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 0000000..bfdf68e --- /dev/null +++ b/wrangler.jsonc @@ -0,0 +1,7 @@ +{ + "name": "2025-e2e-test-1", + "compatibility_date": "2025-08-01", + "assets": { + "directory": "./dist/*" + } +} \ No newline at end of file From bc94fe41507e99fcd42e2495f00067d06485cd33 Mon Sep 17 00:00:00 2001 From: 5509 Date: Wed, 6 Aug 2025 08:56:29 +0900 Subject: [PATCH 2/3] update playwright.yml --- .github/workflows/playwright.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 5827958..3afc939 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -43,11 +43,23 @@ jobs: - name: Run Playwright tests run: npm run test - # Step 6: テスト結果レポートをアーティファクトとして保存 + # Step 6: publicディレクトリとテスト結果を統合 + - name: Run Build for Cloudflare + run : npm run build-for-cf + + # Step 7: distディレクトリをアーティファクトとして保存 # テストが成功・失敗に関わらず(if: always())レポートを保存 - uses: actions/upload-artifact@v4 if: always() # テスト結果に関係なく常に実行 with: - name: playwright-report # アーティファクトの名前 - path: playwright-report/ # レポートファイルのパス - retention-days: 30 # レポートの保存期間(30日間) + name: dist # アーティファクトの名前 + path: dist/ # レポートファイルのパス + retention-days: 30 # レポートの保存期間(30日間) + + # Step 8: Cloudflare Workersにデプロイ + - name: Publish to Cloudflare Workers + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + accountId: ${{ secrets.CF_ACCOUNT_ID }} + command: publish \ No newline at end of file From 323e6cfb502e9cde2a3d3dbed19e1fa204a50b05 Mon Sep 17 00:00:00 2001 From: 5509 Date: Wed, 6 Aug 2025 12:20:43 +0900 Subject: [PATCH 3/3] deploy to pages --- .github/workflows/playwright.yml | 34 +++++++++++++++++++++++--------- package.json | 2 +- wrangler.jsonc | 7 ------- 3 files changed, 26 insertions(+), 17 deletions(-) delete mode 100644 wrangler.jsonc diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 3afc939..083cdb4 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,6 +1,7 @@ # Playwright E2Eテスト自動実行ワークフロー # このワークフローは、mainブランチへのpushやPull Request時に # 自動的にPlaywrightテストを実行し、結果をレポートとして保存します +# また、GitHub Pagesにpublicディレクトリとテスト結果(playwright-report)をデプロイします name: Playwright Tests # ワークフローが実行されるトリガー条件を定義 @@ -12,6 +13,11 @@ on: pull_request: branches: [main] +permissions: + contents: read + pages: write + id-token: write + jobs: # テスト実行ジョブの定義 test: @@ -41,13 +47,18 @@ jobs: # Step 5: 実際のPlaywrightテストを実行 # package.jsonのtestスクリプト(playwright test)を実行 - name: Run Playwright tests - run: npm run test + run: npx playwright test # Step 6: publicディレクトリとテスト結果を統合 - name: Run Build for Cloudflare - run : npm run build-for-cf + run : npm run build-for-pages + + # Step 7: GitHub Pagesの設定 + - name: Setup Pages + uses: actions/configure-pages@v5 + if: always() - # Step 7: distディレクトリをアーティファクトとして保存 + # Step 8: distディレクトリをアーティファクトとして保存 # テストが成功・失敗に関わらず(if: always())レポートを保存 - uses: actions/upload-artifact@v4 if: always() # テスト結果に関係なく常に実行 @@ -56,10 +67,15 @@ jobs: path: dist/ # レポートファイルのパス retention-days: 30 # レポートの保存期間(30日間) - # Step 8: Cloudflare Workersにデプロイ - - name: Publish to Cloudflare Workers - uses: cloudflare/wrangler-action@v3 + # Step 9: GitHub Pagesにアーティファクトをアップロード + - name: Upload Artifacts to GitHub Pages + uses: actions/upload-pages-artifact@v3 + if: always() with: - apiToken: ${{ secrets.CF_API_TOKEN }} - accountId: ${{ secrets.CF_ACCOUNT_ID }} - command: publish \ No newline at end of file + path: ./dist + + # Step 10: GitHub Pagesにデプロイ + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + if: always() \ No newline at end of file diff --git a/package.json b/package.json index 059e960..77750c7 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "test:debug": "node_modules/.bin/playwright test --debug", "serve": "npx http-server public -p 3000", "install-playwright": "npx playwright install", - "build-for-cf": "mkdir -p dist && cp -r public/* dist/ && cp -r playwright-report/index.html dist/playwright-report.html" + "build-for-pages": "mkdir -p dist && cp -r public/* dist/ && cp -r playwright-report dist/playwright-report" }, "keywords": [ "playwright", diff --git a/wrangler.jsonc b/wrangler.jsonc deleted file mode 100644 index bfdf68e..0000000 --- a/wrangler.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "2025-e2e-test-1", - "compatibility_date": "2025-08-01", - "assets": { - "directory": "./dist/*" - } -} \ No newline at end of file