From 1fcc518feae1eee44d826f50c0c6d90bdeaab817 Mon Sep 17 00:00:00 2001 From: para7 Date: Wed, 1 May 2024 15:29:34 +0900 Subject: [PATCH] cicd setup --- .github/workflows/actions.yml | 40 ++++++++++++++++++++++ .github/workflows/pages-deployment.yml | 46 ++++++++++++++++++++++++++ Makefile | 2 +- remix/package.json | 2 +- remix/src/routes/_index.tsx | 41 +++++++++++------------ 5 files changed, 108 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/actions.yml create mode 100644 .github/workflows/pages-deployment.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..12dfe50 --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,40 @@ +name: build +run-name: build check + +on: + pull_request: + push: + branches: + - main + - release + +jobs: + build: + runs-on: ubuntu-22.04 + strategy: + matrix: + node-version: [20] + defaults: + run: + working-directory: remix + steps: + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v3 + with: + version: 9 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + cache-dependency-path: remix + - name: Install dependencies + run: pnpm install --frozen-lockfile + + # チェック実行 + # - name: vitest + # run: pnpm test:ci + # - name: lint + # run: pnpm lint:ci + - name: build check + run: pnpm build diff --git a/.github/workflows/pages-deployment.yml b/.github/workflows/pages-deployment.yml new file mode 100644 index 0000000..4c26404 --- /dev/null +++ b/.github/workflows/pages-deployment.yml @@ -0,0 +1,46 @@ +name: deploy +run-name: deploy to cloudflare + +on: + push: + branches: + - main + - release + +jobs: + deploy: + runs-on: ubuntu-22.04 + permissions: + contents: read + deployments: write + name: Deploy to Cloudflare Pages + defaults: + run: + working-directory: remix + steps: + - name: Checkout + uses: actions/checkout@v3 + # setup env + - uses: pnpm/action-setup@v3 + with: + version: 9 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + cache-dependency-path: remix + # builds + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: build + run: pnpm build + + - name: Publish + uses: cloudflare/pages-action@1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: portfolio # e.g. 'my-project' + directory: remix/build/client # e.g. 'dist' + gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index b3745a7..4a51ab2 100755 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ build: util/build remix/node_modules ## run build docker compose run --rm front_dev /bin/sh -c "pnpm run build" start: util/build ## start builded server - docker compose run --rm -p 127.0.0.1:3000:3000 front_dev /bin/sh -c "pnpm run start" + docker compose run --rm -p 127.0.0.1:8788:8788 front_dev /bin/sh -c "pnpm run start" vrt: util/build remix/node_modules ## run visual regression test diff --git a/remix/package.json b/remix/package.json index b06b40e..7583969 100755 --- a/remix/package.json +++ b/remix/package.json @@ -8,7 +8,7 @@ "deploy": "pnpm run build && wrangler pages deploy", "dev": "remix vite:dev --host 0.0.0.0", "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "wrangler pages dev ./build/client", + "start": "wrangler pages dev ./build/client --ip 0.0.0.0", "ladle": "ladle", "typecheck": "tsc", "typegen": "wrangler types", diff --git a/remix/src/routes/_index.tsx b/remix/src/routes/_index.tsx index 09a7c27..f1ec2ab 100755 --- a/remix/src/routes/_index.tsx +++ b/remix/src/routes/_index.tsx @@ -13,26 +13,25 @@ export const meta: MetaFunction = () => { export default function Index() { return ( - -
-

Welcome to Remix (with Vite and Cloudflare)

- -
-
+
+

Welcome to Remix (with Vite and Cloudflare)

+ +
); }