Skip to content

Commit

Permalink
Custom action for documentation deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
thokra-nav committed Dec 18, 2024
1 parent 517ac6c commit eec38e7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 59 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/publish_doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and deploy Docs

on:
push:
tags:
- "@nais/ds-svelte-community@*"
workflow_dispatch:

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
# Build docs
build_doc:
runs-on: ubuntu-latest
# Only run if @nais/ds-svelte-community is published and version does not contain "-next."
# It's done with some suboptimal string matching, but it works for now.
steps:
- uses: actions/checkout@v4

- name: Install asdf
uses: asdf-vm/actions/setup@v3

- name: asdf cache
id: asdf-cache
uses: actions/cache@v4
with:
path: ~/.asdf/
key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }}

- name: Install CD tools from .tool-versions
if: steps.asdf-cache.outputs.cache-hit != 'true'
uses: asdf-vm/actions/install@v3

- name: Install dependencies
run: |
bun install --frozen-lockfile
bun run build:libs
- name: Build docs
env:
BASE_PATH: "/${{ github.event.repository.name }}"
run: |
cd packages/ds-svelte-community
bun run build:docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: packages/ds-svelte-community/build/

# Deploy job
deploy:
needs: build_doc

permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

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 # or the latest "vX.X.X" version tag for this action
59 changes: 0 additions & 59 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,62 +63,3 @@ jobs:
# export ACTUAL_RELEASE=$(echo "${{ steps.changesets.outputs.publishedPackages }}" | jq '.[] | select(.name == "@nais/ds-svelte-community") | .version | contains("-next.") | not')
export ACTUAL_RELEASE=true
echo "ACTUAL_RELEASE=$ACTUAL_RELEASE" >> $GITHUB_OUTPUT
# Build docs
build_doc:
runs-on: ubuntu-latest
needs: release
# Only run if @nais/ds-svelte-community is published and version does not contain "-next."
# It's done with some suboptimal string matching, but it works for now.
if: ${{ needs.release.outputs.published == 'true' && needs.release.outputs.actual_release == 'true' }}
steps:
- uses: actions/checkout@v4

- name: Install asdf
uses: asdf-vm/actions/setup@v3

- name: asdf cache
id: asdf-cache
uses: actions/cache@v4
with:
path: ~/.asdf/
key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }}

- name: Install CD tools from .tool-versions
if: steps.asdf-cache.outputs.cache-hit != 'true'
uses: asdf-vm/actions/install@v3

- name: Install dependencies
run: |
bun install --frozen-lockfile
bun run build:libs
- name: Build docs
env:
BASE_PATH: "/${{ github.event.repository.name }}"
run: |
cd packages/ds-svelte-community
bun run build:docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: packages/ds-svelte-community/build/

# Deploy job
deploy:
needs: build_doc

permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

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 # or the latest "vX.X.X" version tag for this action

0 comments on commit eec38e7

Please sign in to comment.