From 90391842af3236747fcd7ea579be0e834efb5f2c Mon Sep 17 00:00:00 2001 From: Herman Jensen Date: Mon, 4 Nov 2024 13:59:58 +0100 Subject: [PATCH] ci: use action from docusaurus docs https://docusaurus.io/docs/deployment#triggering-deployment-with-github-actions --- .github/workflows/publish-docs.yml | 38 +++++++++++++++++------- .github/workflows/test-publish-docs.yaml | 28 +++++++++++++++++ 2 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/test-publish-docs.yaml diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 429da16b..c4732b24 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -9,7 +9,7 @@ on: - ".github/workflows/publish-docs.yml" jobs: - gh-release: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -18,13 +18,31 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 + cache: npm + + - name: cd to docusaurus + run: cd docusaurus + - name: Install dependencies + run: npm ci - name: Build - run: | - cd docusaurus - npm ci - npm run build - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docusaurus/build + run: npm run 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 + + # 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 diff --git a/.github/workflows/test-publish-docs.yaml b/.github/workflows/test-publish-docs.yaml new file mode 100644 index 00000000..6043e601 --- /dev/null +++ b/.github/workflows/test-publish-docs.yaml @@ -0,0 +1,28 @@ +name: Test deployment + +on: + pull_request: + branches: + - main + # 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 + +jobs: + test-deploy: + name: Test deployment + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: cd to docusaurus + run: cd docusaurus + - name: Install dependencies + run: npm ci + - name: Test build website + run: npm run build