## 経緯 beta版として[[GitHub Actions]]からの[[GitHub Pages]]が展開されていたので。 <div class="link-card"> <div class="link-card-header"> <img src="https://docs.github.com/assets/cb-803/images/site/favicon.svg" class="link-card-site-icon"/> <span class="link-card-site-name">GitHub Docs</span> </div> <div class="link-card-body"> <div class="link-card-content"> <div> <p class="link-card-title">Configuring a publishing source for your GitHub Pages site - GitHub Docs</p> </div> <div class="link-card-description"> You can configure your GitHub Pages site to publish when changes are pushed to a specific branch, or... </div> </div> <img src="https://github.githubassets.com/images/modules/open_graph/github-logo.png" class="link-card-image" /> </div> <a href="https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow"></a> </div> 都度コミットするのは個人的に微妙だと思っていたから、もしそれが防げるなら試してみたい。そういう仕様なのかもわかっていない。 ## [[GitHub Pages]]の設定 `Source`を`GitHub Actions`に指定するだけでいいはず。 ![[Pasted image 20231022121217.png]] [[Jekyll]]を使ったり、はじめから成果物がコミットされている場合は、suggested workflowが使えそう。今回は[[🧊Obsidian Tempura]]のソースファイルから[[TypeDoc]]を使って静的ページを生成するため、この辺の設定は不要なはず。 ## [[GitHub Actions]]のワークフロー作成 [[ワークフロー (GitHub Actions)|ワークフロー]]を作成する。 [[upload-pages-artifact]]のアクションだけで目的は達成できると思っていたが、色々調べていると怪しい気配がしてきた。。 <div class="link-card"> <div class="link-card-header"> <img src="https://github.githubassets.com/favicons/favicon.svg" class="link-card-site-icon"/> <span class="link-card-site-name">GitHub</span> </div> <div class="link-card-body"> <div class="link-card-content"> <div> <p class="link-card-title">Confusing README? · Issue #6 · actions/upload-pages-artifact</p> </div> <div class="link-card-description"> Context First off, thanks, I've managed to make use of this action within my own custom GH Action wo... </div> </div> <img src="https://opengraph.githubassets.com/7eb9d3d1b57bb1cfa9f245c971789d600f667ac87e0143288a276c12f10cc688/actions/upload-pages-artifact/issues/6" class="link-card-image" /> </div> <a href="https://github.com/actions/upload-pages-artifact/issues/6"></a> </div> 最終的に、以下を参考にするのがよさそう。 <div class="link-card"> <div class="link-card-header"> <img src="https://github.githubassets.com/favicons/favicon.svg" class="link-card-site-icon"/> <span class="link-card-site-name">GitHub</span> </div> <div class="link-card-body"> <div class="link-card-content"> <div> <p class="link-card-title">starter-workflows/pages/static.yml at main · actions/starter-workflows</p> </div> <div class="link-card-description"> Accelerating new GitHub Actions workflows . Contribute to actions/starter-workflows development by c... </div> </div> <img src="https://opengraph.githubassets.com/0fc139e3b1f978c3b3b8e86c24ff19409cb3f1454756773f953b3b88176f02c0/actions/starter-workflows" class="link-card-image" /> </div> <a href="https://github.com/actions/starter-workflows/blob/main/pages/static.yml"></a> </div> ```yaml # Simple workflow for deploying static content to GitHub Pages name: Deploy static content to Pages on: # Runs on pushes targeting the default branch push: branches: [$default-branch] # 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 only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: group: "pages" cancel-in-progress: false jobs: # Single deploy job since we're just deploying deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Setup Pages uses: actions/configure-pages@v3 - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: # Upload entire repository path: '.' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 ``` これを参考に以下の[[ジョブ (GitHub Actions)|ジョブ]]を追加。 ```yaml deploy-docs: runs-on: ubuntu-latest permissions: contents: read pages: write id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - uses: actions/checkout@v3 - uses: actions/configure-pages@v3 - uses: actions/upload-pages-artifact@v2 with: path: 'docs' - uses: actions/deploy-pages@v2 id: deployment ``` ## エラー - [[📝GitHub ActionsでGitHub Pagesをデプロイしようとするとenvironment protection rulesのエラーになる]]