質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
GitHub Pages

GitHub Pagesは、GitHubが提供するホスティングサービス。ブログやプロジェクトのWebページをGit/GitHubのリポジトリを用いて簡単に公開できます。静的Webページのためのホスティングサービスで、GitHubのアカウントがあれば無料での利用が可能です。

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

TypeScript

TypeScriptは、マイクロソフトによって開発された フリーでオープンソースのプログラミング言語です。 TypeScriptは、JavaScriptの構文の拡張であるので、既存の JavaScriptのコードにわずかな修正を加えれば動作します。

Q&A

解決済

2回答

758閲覧

github pagesに自動でデプロイしたい

shintani08

総合スコア3

GitHub Pages

GitHub Pagesは、GitHubが提供するホスティングサービス。ブログやプロジェクトのWebページをGit/GitHubのリポジトリを用いて簡単に公開できます。静的Webページのためのホスティングサービスで、GitHubのアカウントがあれば無料での利用が可能です。

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

TypeScript

TypeScriptは、マイクロソフトによって開発された フリーでオープンソースのプログラミング言語です。 TypeScriptは、JavaScriptの構文の拡張であるので、既存の JavaScriptのコードにわずかな修正を加えれば動作します。

0グッド

0クリップ

投稿2022/10/11 07:15

編集2022/10/11 15:51

起きているエラー

TypeScript × reactで開発しています。
pushした後のgithub上のActionsで下のエラーが発生します。

Run touch ./out/.nojekyll touch ./out/.nojekyll shell: /usr/bin/bash -e {0} touch: cannot touch './out/.nojekyll': No such file or directory Error: Process completed with exit code 1.

実現したいこと

・master branchにpushしたときにActionsが回る
・gh-pagesブランチがなかったら作られる
・gh-pagesをgithub pagesでデプロイする

github/workflows/

test.yml

1name: Test 2 3on: push 4 5jobs: 6 test: 7 name: Test 8 runs-on: ubuntu-latest 9 steps: 10 - uses: actions/checkout@v2 11 - name: setup Node.js 12 uses: actions/setup-node@v1 13 with: 14 node-version: 14 15 - uses: actions/cache@v2 16 id: client-yarn-cache 17 with: 18 path: 'node_modules' 19 key: client-yarn-${{ hashFiles('yarn.lock') }} 20 - run: yarn install 21 if: steps.client-yarn-cache.outputs.cache-hit != 'true' 22 - run: yarn lint 23 - run: yarn typecheck

deploy_client.yml

1name: Deploy client 2 3on: 4 push: co 5 branches: 6 - master 7 8jobs: 9 deploy: 10 name: Deploy 11 runs-on: ubuntu-latest 12 steps: 13 - uses: actions/checkout@v2 14 - uses: actions/setup-node@v1 15 with: 16 node-version: 14 17 - uses: actions/cache@v2 18 id: yarn-cache 19 with: 20 path: 'node_modules' 21 key: client-yarn-${{ hashFiles('yarn.lock') }} 22 - run: yarn install 23 if: steps.client-yarn-cache.outputs.cache-hit != 'true' 24 - run: yarn build 25 - run: touch ./out/.nojekyll 26 - uses: peaceiris/actions-gh-pages@v3 27 with: 28 github_token: ${{ secrets.GITHUB_TOKEN }} 29 publish_dir: ./out 30

試したこと

・masterブランチをそのままデプロイする
=>README.mdが表示される。

備考

不足している情報があれば追記するので教えていただきますようお願い致します。
回答ありがとうございます。回答を試して出Actionsでのエラーになります。

Run yarn build && touch ./out/.nojekyll yarn run v1.22.19 $ next build warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache Attention: Next.js now collects completely anonymous telemetry regarding usage. This information is used to shape Next.js' roadmap and prioritize features. You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL: https://nextjs.org/telemetry info - Linting and checking validity of types... warn - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config info - Creating an optimized production build... info - Compiled successfully info - Collecting page data... info - Generating static pages (0/3) info - Generating static pages (3/3) info - Finalizing page optimization... Route (pages) Size First Load JS ┌ ○ / 41.3 kB 119 kB ├ /_app 0 B 78 kB └ ○ /404 182 B 78.2 kB + First Load JS shared by all 78.3 kB ├ chunks/framework-ed075df0e0b45174.js 45.5 kB ├ chunks/main-e7a7892cb0edc024.js 31 kB ├ chunks/pages/_app-26d2fe1e69b98d42.js 503 B ├ chunks/webpack-7e0a04d6d1a844f2.js 1.04 kB └ css/ab44ce7add5c3d11.css 247 B ○ (Static) automatically rendered as static HTML (uses no initial props) Done in 17.63s. touch: cannot touch './out/.nojekyll': No such file or directory Error: Process completed with exit code 1.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

test.ymlファイルで実行したいテストの内容を書きます。今回はeslint

test.yml

1name: Test 2 3on: push 4 5jobs: 6 test: 7 name: Test 8 runs-on: ubuntu-latest 9 steps: 10 - uses: actions/checkout@v2 11 - name: setup Node.js 12 uses: actions/setup-node@v1 13 with: 14 node-version: 14 15 - uses: actions/cache@v2 16 id: client-yarn-cache 17 with: 18 path: 'node_modules' 19 key: client-yarn-${{ hashFiles('yarn.lock') }} 20 - run: yarn install 21 if: steps.client-yarn-cache.outputs.cache-hit != 'true' 22 - run: yarn lint 23 - run: yarn typecheck

そしてデプロイするファイルがこちらになります

name: Deploy Next.js site to Pages on: # Runs on pushes targeting the default branch push: branches: ["master"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write # Allow one concurrent deployment concurrency: group: "pages" cancel-in-progress: true jobs: # Build job build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Detect package manager id: detect-package-manager run: | if [ -f "${{ github.workspace }}/yarn.lock" ]; then echo "::set-output name=manager::yarn" echo "::set-output name=command::install" echo "::set-output name=runner::yarn" exit 0 elif [ -f "${{ github.workspace }}/package.json" ]; then echo "::set-output name=manager::npm" echo "::set-output name=command::ci" echo "::set-output name=runner::npx --no-install" exit 0 else echo "Unable to determine packager manager" exit 1 fi - name: Setup Node uses: actions/setup-node@v3 with: node-version: "16" cache: ${{ steps.detect-package-manager.outputs.manager }} - name: Setup Pages uses: actions/configure-pages@v2 with: # Automatically inject basePath in your Next.js configuration file and disable # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). # # You may remove this line if you want to manage the configuration yourself. static_site_generator: next - name: Restore cache uses: actions/cache@v3 with: path: | .next/cache # Generate a new cache whenever packages or source files change. key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} # If source files changed but packages didn't, rebuild from a prior cache. restore-keys: | ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- - name: Install dependencies run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} - name: Build with Next.js run: ${{ steps.detect-package-manager.outputs.runner }} next build - name: Static HTML export with Next.js run: ${{ steps.detect-package-manager.outputs.runner }} next export - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: path: ./out # Deployment job deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest needs: build steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v1

投稿2022/10/11 21:23

shintani08

総合スコア3

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

エラーとしては、./out/ディレクトリが存在しないために .nojekyllファイルを作成できない、という流れのように読めます。

以下は推測ですが、yarn buildの run コマンドが終わる前に、非同期的に次のtouchのrunコマンドが実行されたりしてるのではないかと予想しました。(違っていたらすみません)

これが正しいとすると、

- run: yarn build - run: touch ./out/.nojekyll ↓ - run yarn build && touch ./out/.nojekyll

とすれば回避できそうな気がします。

投稿2022/10/11 07:36

kazto

総合スコア7196

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

shintani08

2022/10/11 16:04

回答ありがとうございます。バイトで返信が遅くなってしまい大変申し訳ありません。 質問を編集して追加しましたがエラーはとれませんでした。。やはり```./out```が存在しないみたいです。
shintani08

2022/10/11 21:21

解決しました!解決方法を記載しておきます! 回答してくださりありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問