Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom action for documentation deploy #165

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading