From 5631528998442c5c744d6a7d16e63bb2b4955e93 Mon Sep 17 00:00:00 2001 From: Vlad Nestorov Date: Sun, 10 Mar 2024 14:59:56 -0400 Subject: [PATCH 1/2] Use GitHub Action publish source Update Github Actions deployment instructions to use the more Github way of doing things, and remove dependency on third party actions. See this for an example successful run: https://github.com/vlad-nestorov/vlad-nestorov.github.io/actions/runs/8224051582/workflow --- website/docs/deployment.mdx | 47 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/website/docs/deployment.mdx b/website/docs/deployment.mdx index 74c566bb2f8d..5fa3ae2df2e8 100644 --- a/website/docs/deployment.mdx +++ b/website/docs/deployment.mdx @@ -348,17 +348,17 @@ Alternatively, you can use SSH (`USE_SSH=true`) to log in. [GitHub Actions](https://help.github.com/en/actions) allow you to automate, customize, and execute your software development workflows right in your repository. -The workflow examples below assume your website source resides in the `main` branch of your repository (the _source branch_ is `main`), and your [publishing source](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) is configured for the `gh-pages` branch (the _deployment branch_ is `gh-pages`). +The workflow examples below assume your website source resides in the `main` branch of your repository (the _source branch_ is `main`), and your [publishing source](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) is configured for [publishing with a custom GitHub Actions Workflow](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). Our goal is that: 1. When a new pull request is made to `main`, there's an action that ensures the site builds successfully, without actually deploying. This job will be called `test-deploy`. -2. When a pull request is merged to the `main` branch or someone pushes to the `main` branch directly, it will be built and deployed to the `gh-pages` branch. After that, the new build output will be served on the GitHub Pages site. This job will be called `deploy`. +2. When a pull request is merged to the `main` branch or someone pushes to the `main` branch directly, it will be built and deployed to GitHub Pages. This job will be called `deploy`. Here are two approaches to deploying your docs with GitHub Actions. Based on the location of your deployment branch (`gh-pages`), choose the relevant tab below: - Source repo and deployment repo are the **same** repository. -- The deployment repo is a **remote** repository, different from the source. +- The deployment repo is a **remote** repository, different from the source. Instructions for this scenario assume [publishing source](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) is the `gh-pages` branch. ```mdx-code-block @@ -367,7 +367,6 @@ Here are two approaches to deploying your docs with GitHub Actions. Based on the While you can have both jobs defined in the same workflow file, the original `deploy` workflow will always be listed as skipped in the PR check suite status, which is not indicative of the actual status and provides no value to the review process. We therefore propose to manage them as separate workflows instead. -We will use a popular third-party deployment action: [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus).
GitHub action files @@ -392,9 +391,6 @@ on: # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on -permissions: - contents: write - jobs: deploy: name: Deploy to GitHub Pages @@ -413,21 +409,30 @@ jobs: - name: Build website run: yarn build - # Popular action to deploy to GitHub Pages: - # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 + - name: Upload Build Artifact + uses: actions/upload-pages-artifact@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - # Build output to publish to the `gh-pages` branch: - publish_dir: ./build - # The following lines assign commit authorship to the official - # GH-Actions bot for deploys to `gh-pages` branch: - # https://github.com/actions/checkout/issues/13#issuecomment-724415212 - # The GH actions bot is used by default if you didn't specify the two fields. - # You can swap them out with your own user credentials. - user_name: github-actions[bot] - user_email: 41898282+github-actions[bot]@users.noreply.github.com + path: build + + deploy: + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + ``` ```yml title=".github/workflows/test-deploy.yml" From 3aaaa6f426bcfad4b8cff2b587a569f49e532036 Mon Sep 17 00:00:00 2001 From: ozakione <29860391+OzakIOne@users.noreply.github.com> Date: Thu, 21 Mar 2024 15:38:25 +0100 Subject: [PATCH 2/2] docs: fix github workflow --- website/docs/deployment.mdx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/website/docs/deployment.mdx b/website/docs/deployment.mdx index 5fa3ae2df2e8..9048c4a4d1ae 100644 --- a/website/docs/deployment.mdx +++ b/website/docs/deployment.mdx @@ -367,7 +367,6 @@ Here are two approaches to deploying your docs with GitHub Actions. Based on the While you can have both jobs defined in the same workflow file, the original `deploy` workflow will always be listed as skipped in the PR check suite status, which is not indicative of the actual status and provides no value to the review process. We therefore propose to manage them as separate workflows instead. -
GitHub action files @@ -392,8 +391,8 @@ on: # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on jobs: - deploy: - name: Deploy to GitHub Pages + build: + name: Build Docusaurus runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -415,12 +414,13 @@ jobs: path: build deploy: + name: Deploy to GitHub Pages needs: build # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source # Deploy to the github-pages environment environment: @@ -432,7 +432,6 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 - ``` ```yml title=".github/workflows/test-deploy.yml"