## 経緯 beta版として[[GitHub Actions]]からの[[GitHub Pages]]が展開されていたので。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://docs.github.com/assets/cb-345/images/site/favicon.png" /> <span class="link-card-v2-site-name">GitHub Docs</span> </div> <div class="link-card-v2-title"> Configuring a publishing source for your GitHub Pages site - GitHub Docs </div> <div class="link-card-v2-content"> You can configure your GitHub Pages site to publish when changes are pushed to a specific branch, or you can wri ... </div> <img class="link-card-v2-image" src="https://docs.github.com/assets/cb-345/images/social-cards/pages.png" /> <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-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" /> <span class="link-card-v2-site-name">GitHub</span> </div> <div class="link-card-v2-title"> Confusing README? · Issue #6 · actions/upload-pages-artifact </div> <div class="link-card-v2-content"> Context First off, thanks, I've managed to make use of this action within my own custom GH Action workflow and i ... </div> <img class="link-card-v2-image" src="https://opengraph.githubassets.com/a466c2023a024b259bb94ae181ad0805a6d544a77bc39dc09760e7bff666d022/actions/upload-pages-artifact/issues/6" /> <a href="https://github.com/actions/upload-pages-artifact/issues/6"></a> </div> 最終的に、以下を参考にするのがよさそう。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" /> <span class="link-card-v2-site-name">GitHub</span> </div> <div class="link-card-v2-title"> starter-workflows/pages/static.yml at main · actions/starter-workflows </div> <div class="link-card-v2-content"> Accelerating new GitHub Actions workflows . Contribute to actions/starter-workflows development by creating an a ... </div> <img class="link-card-v2-image" src="https://opengraph.githubassets.com/201cc4bade36f7e51009ca1c86ca96011db5a1ac51affd5400905b7e705ace70/actions/starter-workflows" /> <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のエラーになる]]