Skip to content
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
120 changes: 120 additions & 0 deletions .github/workflows/build-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Build Docs

on:
workflow_call:
inputs:
DEPLOY:
description: 'Flag to deploy the docs'
required: false
type: boolean
default: false
VERSION:
description: 'Version to tag the release with'
required: false
type: string
default: "0"
secrets:
CI_GITHUB_TOKEN:
required: true

outputs:
artifact-uploaded:
value: ${{ jobs.build-docs.outputs.artifact-uploaded }}
product:
value: ${{ jobs.build-docs.outputs.product }}
component:
value: ${{ jobs.build-docs.outputs.component }}

jobs:
build-docs:
runs-on: ubuntu-latest
container: zepben/pipeline-docusaurus
outputs:
artifact-uploaded: ${{ steps.artifact.outputs.uploaded }}
product: ${{ steps.docs-component.outputs.product }}
component: ${{ steps.docs-component.outputs.component }}
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
DOCS_TITLE: ${{ vars.DOCS_TITLE }}
PRODUCT: ${{ vars.PRODUCT }}
steps:

- uses: actions/checkout@v4
with:
token: ${{ env.GITHUB_TOKEN }}

- name: Work around git permission issue
run: |
dname=$(echo ${{github.repository}} | cut -d'/' -f2)
git config --global --add safe.directory /__w/$dname/$dname
shell: sh

- name: Check that DOCS_TITLE and PRODUCT are properly defined in the repo
run: |
if [[ -d docs/site-config && -z $DOCS_TITLE ]]; then
echo "The \$DOCS_TITLE environment variable needs to be set on this repo!"
exit 1
fi
if [[ ! -z $PRODUCT && $PRODUCT != "evolve" && $PRODUCT != "ednar" ]]; then
echo "The only supported values for \$PRODUCT environment variable are 'evolve' and 'ednar'! It's currently set to '$PRODUCT'"
exit 1
fi
shell: bash

- name: Fetch the document component name
id: docs-component
shell: sh {0}
run: |
# Figure out the product type
product=${PRODUCT:-"evolve"}
echo "product=$product" >> "${GITHUB_OUTPUT}"

# This is a project/component name, both for the docs slug and for the proper directory under zepben.github.io {product}/docs/{component}
echo "component=$(echo ${GITHUB_REPOSITORY} | cut -f2 -d\/)" >> "${GITHUB_OUTPUT}"

- name: Build docusaurus
id: build
uses: zepben/docusaurus-action@main
with:
VERSION: ${{ inputs.VERSION }}
NPM_REPO: ${{ secrets.NPM_REPO }}
NPM_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
DOCS_TITLE: ${{ env.DOCS_TITLE }}
PRODUCT: ${{ env.PRODUCT }}
continue-on-error: true

- name: Failed build
if: steps.build.outcome == 'failure'
run: |
echo "There was an error in the docusaurus build above. Docs are not pushed"
echo " :boom: There was an error in the docusaurus build step. Current docs are not published" >> ${GITHUB_STEP_SUMMARY}
shell: sh

- name: Check if we need to skip deployment for hotfix or LTS branch
if: ${{ inputs.DEPLOY }}
run: |
if [[ ${GITHUB_REF_NAME} =~ "hotfix" || ${GITHUB_REF_NAME} =~ "LTS" ]]; then
echo "deployDocs=no" >> ${GITHUB_ENV}
echo "Running on LTS or hotfix branch, skip deploying docs"
else
echo "deployDocs=yes" >> ${GITHUB_ENV}
fi

- name: Zip documentation
if: ${{ env.deployDocs == 'yes' }}
run: |
cd docs/build
zip -r ../../docs.zip .
shell: bash

- uses: actions/upload-artifact@v4
if: ${{ steps.build.outcome == 'success' && env.deployDocs == 'yes' }}
id: upload
with:
name: docs.zip
path: docs.zip

- if: ${{ steps.upload.outcome == 'success' }}
id: artifact
run:
echo "uploaded=yes" >> "${GITHUB_OUTPUT}"
75 changes: 6 additions & 69 deletions .github/workflows/csharp-app-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,76 +228,13 @@ jobs:
shell: bash

build-docs:
needs: release-checks
runs-on: ubuntu-latest
needs: [release-checks]
if: ${{ needs.release-checks.outputs.docs-present == 'yes' }}
outputs:
artifact: docs
container: zepben/pipeline-docusaurus
steps:
- name: Install Git
run: |
apk add git zip

- name: Work around git permission issue
run: |
dname=$(echo ${{github.repository}} | cut -d'/' -f2)
git config --global --add safe.directory /__w/$dname/$dname
shell: sh

- uses: actions/checkout@v4

- name: Check that title is defined in the repo
run: |
if [[ -d docs/site-config && -z $DOCS_TITLE ]]; then
echo "The \$DOCS_TITLE environment variable needs to be set on this repo!"
fi
env:
DOCS_TITLE: ${{ vars.DOCS_TITLE }}
shell: bash

- name: Checkout release branch
run: |
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch --all
git checkout release
shell: sh

- name: Cache nodejs deps
uses: actions/cache@v4
with:
path: ~/.npm
key: npm

- name: Build docusaurus
id: build
uses: zepben/docusaurus-action@main
with:
VERSION: ${{ needs.release-checks.outputs.version }}
NPM_REPO: ${{ secrets.NPM_REPO }}
NPM_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
DOCS_TITLE: ${{ vars.DOCS_TITLE }}
continue-on-error: true

- name: Zip documentation
run: |
cd docs/build
zip -r ../../docs.zip .
shell: sh

- uses: actions/upload-artifact@v4
if: steps.build.outcome == 'success'
with:
name: docs.zip
path: docs.zip

- name: Fail build
if: steps.build.outcome == 'failure'
run: |
git push origin -d release
echo "There was an error in the docusaurus build above."
exit 1
shell: sh
uses: ./.github/workflows/build-docs.yaml
with:
DEPLOY: true
VERSION: ${{ needs.release-checks.outputs.version }}
secrets: inherit


create-release:
Expand Down
83 changes: 5 additions & 78 deletions .github/workflows/csharp-app-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,85 +198,12 @@ jobs:
path: ${{ env.artifact_id }}/bin/Release/

build-docs:
runs-on: ubuntu-latest
container: zepben/pipeline-docusaurus
needs: [build-app]
if: ${{ needs.build-app.outputs.docs-present == 'yes' }}
outputs:
artifact-uploaded: ${{ steps.artifact.outputs.uploaded }}
product-key: ${{ steps.docs-component.outputs.name }}
product-repo: ${{ steps.docs-component.outputs.repo }}
steps:
- uses: actions/checkout@v4

- name: Check that title is defined in the repo
run: |
if [[ -d docs/site-config && -z $DOCS_TITLE ]]; then
echo "The \$DOCS_TITLE environment variable needs to be set on this repo!"
exit 1
fi
env:
DOCS_TITLE: ${{ vars.DOCS_TITLE }}
shell: bash

- name: Build docusaurus
id: build
uses: zepben/docusaurus-action@main
with:
TAG: false
NPM_REPO: ${{ secrets.NPM_REPO }}
NPM_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
continue-on-error: true

- name: Failed build
if: steps.build.outcome == 'failure'
run: |
echo "There was an error in the docusaurus build above. Docs are not pushed"
echo " :boom: There was an error in the docusaurus build step. Current docs are not published" >> ${GITHUB_STEP_SUMMARY}
shell: sh

- name: Check if we need to skip deployment for hotfix or LTS branch
run: |
if [[ ${GITHUB_REF_NAME} =~ "hotfix" || ${GITHUB_REF_NAME} =~ "LTS" ]]; then
echo "deployDocs=no" >> ${GITHUB_ENV}
echo "Running on LTS or hotfix branch, skip deploying docs"
else
echo "deployDocs=yes" >> ${GITHUB_ENV}
fi

- name: Zip documentation
if: ${{ env.deployDocs == 'yes' }}
run: |
cd docs/build
zip -r ../../docs.zip .
shell: bash

- uses: actions/upload-artifact@v4
if: ${{ steps.build.outcome == 'success' && env.deployDocs == 'yes' }}
id: upload
with:
name: docs.zip
path: docs.zip

- if: ${{ steps.upload.outcome == 'success' }}
id: artifact
run:
echo "uploaded=yes" >> "${GITHUB_OUTPUT}"

- name: Fetch the document component name
id: docs-component
shell: sh {0}
run: |
echo "repo=${GITHUB_REPOSITORY}" >> "${GITHUB_OUTPUT}"
# if product key is supplied
if [ "${{ inputs.product-key }}" != "productkeynotprovided" ]; then
echo "name=${{ inputs.product-key }}" >> "${GITHUB_OUTPUT}"
else
# parse out the product key from the repository name
echo "name=$(echo ${GITHUB_REPOSITORY} | cut -f2 -d\/)" >> "${GITHUB_OUTPUT}"
fi


uses: ./.github/workflows/build-docs.yaml
with:
DEPLOY: true
secrets: inherit

deploy-docs:
runs-on: ubuntu-latest
Expand All @@ -289,4 +216,4 @@ jobs:
token: ${{ secrets.CI_GITHUB_TOKEN }}
repository: ${{ secrets.DOCS_REPO }}
event-type: ${{ secrets.DOCS_REPO_EVOLVE_WORKFLOW }}
client-payload: '{"product_key": "${{needs.build-docs.outputs.product-key}}", "download_url": "${{needs.build-docs.outputs.product-repo}}"}'
client-payload: '{"product": "${{needs.build-docs.outputs.product}}", "product_key": "${{needs.build-docs.outputs.component}}", "download_url": "${{github.repository}}"}'
28 changes: 3 additions & 25 deletions .github/workflows/csharp-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,29 +185,7 @@ jobs:
run: vstest.console.exe ${{ inputs.test_files }} /Platform:${{ inputs.platform }}

build-docs:
runs-on: ubuntu-latest
needs: checks
needs: [checks]
if: ${{ needs.checks.outputs.docs-present == 'yes' }}
container: zepben/pipeline-docusaurus
steps:

- uses: actions/checkout@v4

- name: Check that title is defined in the repo
run: |
if [[ -d docs/site-config && -z $DOCS_TITLE ]]; then
echo "The \$DOCS_TITLE environment variable needs to be set on this repo!"
exit 1
fi
env:
DOCS_TITLE: ${{ vars.DOCS_TITLE }}
shell: bash

- name: Build docusaurus
id: build
uses: zepben/docusaurus-action@main
with:
TAG: false
NPM_REPO: ${{ secrets.NPM_REPO }}
NPM_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
DOCS_TITLE: ${{ vars.DOCS_TITLE }}
uses: ./.github/workflows/build-docs.yaml
secrets: inherit
Loading