diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml new file mode 100644 index 0000000..23bf21c --- /dev/null +++ b/.github/workflows/build-docs.yaml @@ -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}" diff --git a/.github/workflows/csharp-app-release.yml b/.github/workflows/csharp-app-release.yml index 14e2304..889037d 100644 --- a/.github/workflows/csharp-app-release.yml +++ b/.github/workflows/csharp-app-release.yml @@ -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: diff --git a/.github/workflows/csharp-app-snapshot.yml b/.github/workflows/csharp-app-snapshot.yml index 0deab92..0113476 100644 --- a/.github/workflows/csharp-app-snapshot.yml +++ b/.github/workflows/csharp-app-snapshot.yml @@ -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 @@ -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}}"}' diff --git a/.github/workflows/csharp-build.yml b/.github/workflows/csharp-build.yml index 1abdc3b..748577e 100644 --- a/.github/workflows/csharp-build.yml +++ b/.github/workflows/csharp-build.yml @@ -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 diff --git a/.github/workflows/maven-app-release.yml b/.github/workflows/maven-app-release.yml index 33c984e..fd4bd23 100644 --- a/.github/workflows/maven-app-release.yml +++ b/.github/workflows/maven-app-release.yml @@ -151,90 +151,13 @@ jobs: build-docs: - needs: release-checks - runs-on: ubuntu-latest + needs: [release-checks] if: ${{ needs.release-checks.outputs.docs-present == 'yes' }} - outputs: - artifact: docs - product-key: ${{ steps.docs-component.outputs.name }} - product-repo: ${{ steps.docs-component.outputs.repo }} - container: zepben/pipeline-docusaurus - steps: - - - 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!" - exit 1 - 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 - if-no-files-found: error - - - 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 - - - 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 + VERSION: ${{ needs.release-checks.outputs.version }} + secrets: inherit deploy: needs: [release-checks, build-docs] @@ -385,11 +308,12 @@ jobs: - name: Deploy documentation uses: peter-evans/repository-dispatch@v1 + if: ${{ needs.build-docs.outputs.artifact-uploaded == 'yes' }} with: 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}}"}' continue-on-error: true update-version: diff --git a/.github/workflows/maven-app-snapshot.yml b/.github/workflows/maven-app-snapshot.yml index 98730c1..500a6dc 100644 --- a/.github/workflows/maven-app-snapshot.yml +++ b/.github/workflows/maven-app-snapshot.yml @@ -162,85 +162,12 @@ jobs: fi 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 }} - DOCS_TITLE: ${{ vars.DOCS_TITLE }} - 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 update-snapshot-version: needs: [build-app] @@ -280,4 +207,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}}"}' diff --git a/.github/workflows/maven-build-oss.yml b/.github/workflows/maven-build-oss.yml index ace60e9..91b252d 100644 --- a/.github/workflows/maven-build-oss.yml +++ b/.github/workflows/maven-build-oss.yml @@ -130,29 +130,7 @@ jobs: fi build-docs: - runs-on: ubuntu-latest - needs: build-and-test + needs: [build-and-test] if: ${{ needs.build-and-test.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 diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index d677d8d..86dacdf 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -167,29 +167,7 @@ jobs: fi build-docs: - runs-on: ubuntu-latest - needs: build-and-test + needs: [build-and-test] if: ${{ needs.build-and-test.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 diff --git a/.github/workflows/maven-lib-release.yml b/.github/workflows/maven-lib-release.yml index d8e585f..a3d90bc 100644 --- a/.github/workflows/maven-lib-release.yml +++ b/.github/workflows/maven-lib-release.yml @@ -158,94 +158,13 @@ jobs: echo "changelog=${new_changelog}" >> $GITHUB_OUTPUT build-docs: - needs: release-checks - runs-on: ubuntu-latest + needs: [release-checks] if: ${{ needs.release-checks.outputs.docs-present == 'yes' }} - outputs: - artifact: docs - product-key: ${{ steps.docs-component.outputs.name }} - product-repo: ${{ steps.docs-component.outputs.repo }} - 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!" - exit 1 - 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 - if-no-files-found: error - - - 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 - - - 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 + VERSION: ${{ needs.release-checks.outputs.version }} + secrets: inherit deploy: needs: [release-checks, build-docs] @@ -253,6 +172,8 @@ jobs: runs-on: ubuntu-latest outputs: artifact: ${{ steps.build.outputs.artifact }} + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} container: zepben/pipeline-java-ewb steps: - name: Work around git permission issue @@ -400,11 +321,12 @@ jobs: - name: Deploy documentation uses: peter-evans/repository-dispatch@v1 + if: ${{ needs.build-docs.outputs.artifact-uploaded == 'yes' }} with: 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}}" }' continue-on-error: true update-version: diff --git a/.github/workflows/maven-lib-snapshot.yml b/.github/workflows/maven-lib-snapshot.yml index 376320c..52ad02b 100644 --- a/.github/workflows/maven-lib-snapshot.yml +++ b/.github/workflows/maven-lib-snapshot.yml @@ -170,83 +170,12 @@ jobs: continue-on-error: true build-docs: - runs-on: ubuntu-latest - container: zepben/pipeline-docusaurus needs: [check-docs] if: ${{ needs.check-docs.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 update-snapshot-version: needs: [deploy] @@ -286,5 +215,5 @@ 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}}" }' diff --git a/.github/workflows/npm-app-build.yml b/.github/workflows/npm-app-build.yml index 25fb331..f1f0a11 100644 --- a/.github/workflows/npm-app-build.yml +++ b/.github/workflows/npm-app-build.yml @@ -166,29 +166,7 @@ jobs: fi build-docs: - runs-on: ubuntu-latest - needs: build-and-test + needs: [build-and-test] if: ${{ needs.build-and-test.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 diff --git a/.github/workflows/npm-app-release.yml b/.github/workflows/npm-app-release.yml index 78fbc1c..123a650 100644 --- a/.github/workflows/npm-app-release.yml +++ b/.github/workflows/npm-app-release.yml @@ -129,98 +129,13 @@ jobs: echo "changelog=${new_changelog}" >> $GITHUB_OUTPUT build-docs: - needs: release-checks - runs-on: ubuntu-latest + needs: [release-checks] if: ${{ needs.release-checks.outputs.docs-present == 'yes' }} - outputs: - artifact: docs - product-key: ${{ steps.docs-component.outputs.name }} - product-repo: ${{ steps.docs-component.outputs.repo }} - container: zepben/pipeline-docusaurus - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - 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 - with: - token: ${{ env.GITHUB_TOKEN }} - - - 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: 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 - if-no-files-found: error - - - 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 - - - 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 + VERSION: ${{ needs.release-checks.outputs.version }} + secrets: inherit build-artifact: needs: [build-docs, release-checks] @@ -300,11 +215,10 @@ jobs: shell: sh create-release: - needs: [release-checks, build-artifact] + needs: [release-checks, build-docs, build-artifact] runs-on: ubuntu-latest outputs: artifact: ${{ steps.merge.outputs.artifact }} - tag: ${{ steps.merge.outputs.tag }} env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} steps: @@ -338,10 +252,9 @@ jobs: git fetch --all git merge origin/release git push origin ${GITHUB_REF/refs\/heads\//} - tag="v${{ needs.release-checks.outputs.version }}" - git tag $tag + git tag "v${{ needs.release-checks.outputs.version }}" git push --tags - echo "tag=$tag" >> $GITHUB_OUTPUT + echo "tag=v${{ needs.release-checks.outputs.version }}" >> $GITHUB_OUTPUT shell: bash continue-on-error: true @@ -396,11 +309,12 @@ jobs: - name: Deploy documentation uses: peter-evans/repository-dispatch@v1 + if: ${{ needs.build-docs.outputs.artifact-uploaded == 'yes' }} with: 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}}"}' update-version: needs: create-release diff --git a/.github/workflows/npm-app-snapshot-release.yml b/.github/workflows/npm-app-snapshot-release.yml index 3f5797a..00a6b01 100644 --- a/.github/workflows/npm-app-snapshot-release.yml +++ b/.github/workflows/npm-app-snapshot-release.yml @@ -152,84 +152,12 @@ jobs: fi build-docs: - runs-on: ubuntu-latest needs: [build-artifact] - container: zepben/pipeline-docusaurus if: ${{ needs.build-artifact.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 }} - DOCS_TITLE: ${{ vars.DOCS_TITLE }} - 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 update-snapshot-version: needs: [build-artifact] @@ -266,5 +194,5 @@ 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}}"}' diff --git a/.github/workflows/npm-lib-release.yml b/.github/workflows/npm-lib-release.yml index 6dc1971..fbb042c 100644 --- a/.github/workflows/npm-lib-release.yml +++ b/.github/workflows/npm-lib-release.yml @@ -34,6 +34,7 @@ jobs: continue-on-error: false outputs: changelog: ${{ steps.changelog.outputs.changelog }} + version: ${{ steps.version.outputs.version }} env: DEBUG: ${{ secrets.DEBUG }} GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} @@ -94,6 +95,7 @@ jobs: artifact: ${{ steps.build.outputs.artifact }} artifact-id: ${{ steps.build.outputs.artifact-id }} version: ${{ steps.build.outputs.version }} + docs-present: ${{ steps.docs.outputs.present }} env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} steps: @@ -147,8 +149,8 @@ jobs: artifact="$(npm pack --foreground-scripts=false --json --dry-run | jq -r .[0].filename)" npm publish version=$(jq -r .version package.json) - echo "::set-output name=version::$(echo $version)" - echo "::set-output name=artifact::$(echo $artifact)" + echo "version=$version" >> "${GITHUB_OUTPUT}" + echo "artifact=$artifact" >> "${GITHUB_OUTPUT}" continue-on-error: true - uses: actions/upload-artifact@v4 @@ -166,6 +168,38 @@ jobs: exit 1 shell: sh + - name: Check if docs present + id: docs + run: | + if [ -d docs ]; then + echo "Docs folder found, will run the build-docs job" + echo "present=yes" >> "${GITHUB_OUTPUT}" + echo "present=yes" >> "${GITHUB_ENV}" + else + echo "Docs folder not found, will skip the build-docs" + fi + + - name: Check doc build artifacts are ignored + if: ${{ env.present == 'yes' }} + shell: sh {0} + run: | + # Make sure directories are properly ignored + # docs/node_modules + git check-ignore -q docs/site-config/project.json + if [ $? != 0 ]; then + echo "ERROR! Make sure to add 'docs/site-config' to .gitignore" + echo "::error line=1::ERROR! Make sure to add 'docs/site-config' to .gitignore" + exit 1 + fi + + build-docs: + needs: [build-artifact] + if: ${{ needs.build-artifact.outputs.docs-present == 'yes' }} + uses: ./.github/workflows/build-docs.yaml + with: + DEPLOY: true + secrets: inherit + create-release: needs: [build-artifact, release-checks] runs-on: ubuntu-latest @@ -174,7 +208,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} outputs: artifact: ${{ steps.merge.outputs.artifact }} - tag: ${{ steps.merge.outputs.tag }} steps: - uses: actions/checkout@v4 with: @@ -213,10 +246,9 @@ jobs: git fetch --all git merge origin/release git push origin ${GITHUB_REF/refs\/heads\//} - version=$(jq -r .version package.json) - git tag "v$version" + git tag "v${{ needs.release-checks.outputs.version }}" git push --tags - echo "tag=v$version" >> $GITHUB_OUTPUT + echo "tag=v${{ needs.release-checks.outputs.version }}" >> $GITHUB_OUTPUT echo "artifact=${{ needs.build-artifact.outputs.artifact }}" >> $GITHUB_OUTPUT shell: bash continue-on-error: true @@ -277,3 +309,17 @@ jobs: run: | /scripts/update-version.sh --js --release --grow-changelog package.json changelog.md shell: bash + + deploy-docs: + runs-on: ubuntu-latest + needs: [build-docs] + if: ${{ needs.build-docs.outputs.artifact-uploaded == 'yes' }} + steps: + - name: Deploy documentation + uses: peter-evans/repository-dispatch@v2 + with: + token: ${{ secrets.CI_GITHUB_TOKEN }} + repository: ${{ secrets.DOCS_REPO }} + event-type: ${{ secrets.DOCS_REPO_EVOLVE_WORKFLOW }} + client-payload: '{"product": "${{needs.build-docs.outputs.product}}", "product_key": "${{needs.build-docs.outputs.component}}", "download_url": "${{github.repository}}"}' + diff --git a/.github/workflows/npm-lib-snapshot.yml b/.github/workflows/npm-lib-snapshot.yml index c13c77f..854765d 100644 --- a/.github/workflows/npm-lib-snapshot.yml +++ b/.github/workflows/npm-lib-snapshot.yml @@ -146,83 +146,12 @@ jobs: fi build-docs: - runs-on: ubuntu-latest needs: [build-artifact] if: ${{ needs.build-artifact.outputs.docs-present == 'yes' }} - container: zepben/pipeline-docusaurus - 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 update-snapshot-version: needs: [build-artifact] @@ -259,5 +188,5 @@ 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}}"}' diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index 0a5715c..5af792b 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -59,19 +59,18 @@ jobs: echo -e "${message}" | gh pr comment ${{ github.event.pull_request.number }} --body-file - fi - build-and-test: + run-checks: runs-on: ubuntu-latest - container: python:3.10 + container: zepben/pipeline-basic + needs: check-for-leaks env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} outputs: docs-present: ${{ steps.docs.outputs.present }} + steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: | - pip install tox + - uses: actions/checkout@v4 - name: Work around git permission issue run: | @@ -91,18 +90,6 @@ jobs: LC_URL: ${{ secrets.LC_URL }} PATH: ${{ inputs.sourcepath }} - - name: Build and test - run: | - tox - shell: bash - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - fail_ci_if_error: false - token: ${{ secrets.CODECOV_TOKEN }} - continue-on-error: true - - name: Check if docs present id: docs run: | @@ -126,45 +113,47 @@ jobs: run: | # Make sure directories are properly ignored # docs/node_modules - git check-ignore -q docs/node_modules + git check-ignore -q docs/site-config/project.json if [ $? != 0 ]; then - echo "ERROR! Make sure to add 'docs/node_modules' to .gitignore" - echo "::error line=1::ERROR! Make sure to add 'docs/node_modules' to .gitignore" + echo "ERROR! Make sure to add 'docs/site-config' to .gitignore" + echo "::error line=1::ERROR! Make sure to add 'docs/site-config' to .gitignore" exit 1 fi - # docs/build - git check-ignore -q docs/build - if [ $? != 0 ]; then - echo "ERROR! Make sure to add 'docs/build' to .gitignore" - echo "::error line=1::ERROR! Make sure to add 'docs/build' to .gitignore" - exit 1 - fi - - build-docs: + build-and-test: runs-on: ubuntu-latest - needs: build-and-test - if: ${{ needs.build-and-test.outputs.docs-present == 'yes' }} - container: zepben/pipeline-docusaurus - steps: + needs: [check-for-leaks, run-checks] + container: python:3.10 + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + steps: - uses: actions/checkout@v4 - - name: Check that title is defined in the repo + - name: Install dependencies 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 }} + pip install tox + + - 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: Build and test + run: | + tox shell: bash - - name: Build docusaurus - id: build - uses: zepben/docusaurus-action@main + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 with: - TAG: false - NPM_REPO: ${{ secrets.NPM_REPO }} - NPM_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - DOCS_TITLE: ${{ vars.DOCS_TITLE }} + fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} + continue-on-error: true + + build-docs: + needs: [run-checks] + if: ${{ needs.run-checks.outputs.docs-present == 'yes' }} + uses: ./.github/workflows/build-docs.yaml + secrets: inherit diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index f76434a..b5bc318 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -153,95 +153,14 @@ jobs: # from zepben packages. Now let's try to install to see if deps exist or fail quick pip install --pre '.' - build-docs: needs: [release-checks, python-deps-check] - runs-on: ubuntu-latest if: ${{ needs.release-checks.outputs.docs-present == 'yes' }} - outputs: - artifact: docs - product-key: ${{ steps.docs-component.outputs.name }} - product-repo: ${{ steps.docs-component.outputs.repo }} - 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!" - exit 1 - 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 - if-no-files-found: error - - - 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 - - - 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 + VERSION: ${{ needs.release-checks.outputs.version }} + secrets: inherit deploy: needs: [release-checks, build-docs] @@ -329,7 +248,7 @@ jobs: - name: Testing release run: | - echo "Product: ${{ needs.build-docs.outputs.product-key }}" + echo "Product: ${{ needs.build-docs.outputs.component }}" - name: Work around git permission issue run: | @@ -347,7 +266,7 @@ jobs: git push origin ${GITHUB_REF/refs\/heads\//} git tag "v${{ needs.release-checks.outputs.version }}" git push --tags - echo "::set-output name=tag::$(echo v${{ needs.release-checks.outputs.version }})" + echo "tag=v${{ needs.release-checks.outputs.version }}" >> "${GITHUB_OUTPUT}" shell: bash continue-on-error: true @@ -390,12 +309,12 @@ jobs: - name: Deploy documentation uses: peter-evans/repository-dispatch@v1 - if: ${{ needs.build-docs.outputs.product-key != '' }} + if: ${{ needs.build-docs.outputs.artifact-uploaded == 'yes' }} with: 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}}"}' continue-on-error: true update-version: diff --git a/.github/workflows/python-lib-snapshot.yml b/.github/workflows/python-lib-snapshot.yml index d292ea2..ef2c2fa 100644 --- a/.github/workflows/python-lib-snapshot.yml +++ b/.github/workflows/python-lib-snapshot.yml @@ -30,21 +30,18 @@ on: required: false jobs: - deploy: + + run-checks: runs-on: ubuntu-latest - container: python:3.10 + container: zepben/pipeline-basic env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - outputs: + outputs: docs-present: ${{ steps.docs.outputs.present }} - # permissions: # Uncomment these when trusted publishing supports reusable workflows OPS-185 - # id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: | - pip install tox twine + - uses: actions/checkout@v4 - name: Work around git permission issue run: | @@ -62,7 +59,60 @@ jobs: uses: zepben/licence-check-action@main with: LC_URL: ${{ secrets.LC_URL }} - PATH: src + PATH: ${{ inputs.sourcepath }} + + - name: Check if docs present + id: docs + run: | + if [ -d docs ]; then + echo "Docs folder found, will run the build-docs job" + echo "present=yes" >> "${GITHUB_OUTPUT}" + echo "present=yes" >> "${GITHUB_ENV}" + else + echo "Docs folder not found, will skip the build-docs" + fi + + - 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 doc build artifacts are ignored + if: ${{ env.present == 'yes' }} + shell: sh {0} + run: | + # Make sure directories are properly ignored + # docs/node_modules + git check-ignore -q docs/site-config/project.json + if [ $? != 0 ]; then + echo "ERROR! Make sure to add 'docs/site-config' to .gitignore" + echo "::error line=1::ERROR! Make sure to add 'docs/site-config' to .gitignore" + exit 1 + fi + + deploy: + runs-on: ubuntu-latest + container: python:3.10 + needs: [run-checks] + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + outputs: + docs-present: ${{ steps.docs.outputs.present }} + # permissions: # Uncomment these when trusted publishing supports reusable workflows OPS-185 + # id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + pip install tox twine + + - 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: Create .pypirc env: @@ -96,44 +146,6 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} continue-on-error: true - - name: Check if docs present - id: docs - run: | - if [ -d docs ]; then - echo "Docs folder found, will run the build-docs job" - echo "present=yes" >> "${GITHUB_OUTPUT}" - echo "present=yes" >> "${GITHUB_ENV}" - else - echo "Docs folder not found, will skip the build-docs" - fi - - - 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 doc build artifacts are ignored - if: ${{ env.present == 'yes' }} - shell: sh {0} - run: | - # Make sure directories are properly ignored - # docs/node_modules - git check-ignore -q docs/node_modules - if [ $? != 0 ]; then - echo "ERROR! Make sure to add 'docs/node_modules' to .gitignore" - echo "::error line=1::ERROR! Make sure to add 'docs/node_modules' to .gitignore" - exit 1 - fi - - # docs/build - git check-ignore -q docs/build - if [ $? != 0 ]; then - echo "ERROR! Make sure to add 'docs/build' to .gitignore" - echo "::error line=1::ERROR! Make sure to add 'docs/build' to .gitignore" - exit 1 - fi - update-snapshot-version: needs: [deploy] container: zepben/pipeline-basic @@ -158,83 +170,12 @@ jobs: shell: bash build-docs: - runs-on: ubuntu-latest - container: zepben/pipeline-docusaurus - needs: [deploy] - if: ${{ needs.deploy.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 + needs: [run-checks] + if: ${{ needs.run-checks.outputs.docs-present == 'yes' }} + uses: ./.github/workflows/build-docs.yaml + with: + DEPLOY: true + secrets: inherit deploy-docs: runs-on: ubuntu-latest @@ -247,5 +188,5 @@ 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}}"}'