Skip to content

Commit

Permalink
ci: documentation website deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
alperensert committed Apr 27, 2024
1 parent d3f86a7 commit 69de15a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
71 changes: 23 additions & 48 deletions .github/workflows/ghpages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,66 +22,41 @@ defaults:

jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "file=**/yarn.lock" >> $GITHUB_OUTPUT
exit 0
elif [ -f "package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "file=**/package.json" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine packager manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
- uses: actions/checkout@v4
with:
node-version: "18"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: ${{ steps.detect-package-manager.outputs.file }}

- name: Setup Pages
id: pages
uses: actions/configure-pages@v2
fetch-depth: 0
- uses: actions/setup-node@v4
with:
static_site_generator: gatsby
- name: Restore cache
uses: actions/cache@v3
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }}
restore-keys: |
${{ runner.os }}-gatsby-build-
node-version: 18
cache: yarn

- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Gatsby
env:
PREFIX_PATHS: 'true'
run: ${{ steps.detect-package-manager.outputs.manager }} run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
run: yarn install --frozen-lockfile
- name: Build website
run: yarn build

- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/public
path: build

deploy:
name: Deploy to GitHub Pages
needs: build

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
26 changes: 26 additions & 0 deletions .github/workflows/test_ghpages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Documentation Deployment

on:
pull_request:
branches:
- master
paths:
- docs/**

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: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Test build website
run: yarn build

0 comments on commit 69de15a

Please sign in to comment.