From 3287b95930c364684d872935d9901735133d3fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=BE=E4=BA=86=E4=B8=AA=E8=90=8C?= <59004461+ambition-echo@users.noreply.github.com> Date: Fri, 13 Jan 2023 17:36:46 +0800 Subject: [PATCH] Use github actions to deploy github pages --- .github/workflows/deploy.yml | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..8029b748 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,58 @@ +# This is a workflow to build and deploy mdbook to github pages + +name: Deploy + +on: + push: + branches: [ main ] + +jobs: + # Build mdBook + build: + runs-on: ubuntu-latest + steps: + # Checks-out your repository under $GITHUB_WORKSPACE + - uses: actions/checkout@v3 + # Install mdBook + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: 'latest' + # Build mdBook + - name: Build mdBook + run: mdbook build + - name: Copy some Files + run: | + cp ./assets/CNAME ./book/ + cp ./assets/*.html ./book/ + cp ./assets/sitemap.xml ./book/ + # Upload artifact + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@v1 + with: + # Artifact name + name: book + # Path of the directory containing the static assets. + path: book/ + + # Deploy to github pages + deploy: + needs: build + runs-on: ubuntu-latest + # 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 }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 + with: + # Name of the artifact to deploy + artifact_name: book