diff --git a/.github/workflows/docs-ci.yml b/.github/workflows/docs-ci.yml new file mode 100644 index 000000000..5ad51c453 --- /dev/null +++ b/.github/workflows/docs-ci.yml @@ -0,0 +1,53 @@ +name: Docs Continuous Integration + +on: + push: + branches: + - main + pull_request: + branches: + - main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + tbdocs-reporter: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + + - name: Install latest npm + run: npm install -g npm@latest + + - name: Install dependencies + run: npm ci + + - name: Build all workspace packages + run: npm run build + + - name: TBDocs Reporter + id: tbdocs-reporter-protocol + uses: TBD54566975/tbdocs@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + report_changed_scope_only: false + fail_on_error: false + entry_points: | + - file: packages/api/src/index.ts + docsReporter: api-extractor + docsGenerator: typedoc-markdown + + - name: Save Artifacts + uses: actions/upload-artifact@v3 + if: always() + with: + name: tbdocs-reporter-output + path: ./.tbdocs diff --git a/.github/workflows/tbdocs-commenter.yml b/.github/workflows/tbdocs-commenter.yml new file mode 100644 index 000000000..83d4b5d3a --- /dev/null +++ b/.github/workflows/tbdocs-commenter.yml @@ -0,0 +1,52 @@ +name: TBDocs Commenter + +on: + workflow_run: + workflows: ["Docs Continuous Integration"] + types: + - completed + +jobs: + comment-action: + name: TBDocs PR Comment + runs-on: ubuntu-latest + # runs only if it's triggered from a PR + if: github.event.workflow_run.pull_requests[0].number != null + + steps: + - name: Download TBDocs Report + uses: dawidd6/action-download-artifact@v2 + with: + run_id: ${{ github.event.workflow_run.id }} + name: tbdocs-reporter-output + path: ./.tbdocs + + - name: Add footer to markdown report + run: | + report_file='.tbdocs/docs-report.md' + head_sha="${{ github.event.workflow_run.pull_requests[0].head.sha }}" + short_sha=${head_sha:0:7} + timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + repo="${{ github.repository }}" + sha_link="https://github.com/$repo/commit/$head_sha" + + footer_line="_TBDocs Report Updated at $timestamp [\`$short_sha\`]($sha_link)_" + + echo "---" >> $report_file + echo $footer_line >> $report_file + + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} + comment-author: "github-actions[bot]" + body-includes: TBDocs Report + + - name: Comment on PR + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} + edit-mode: replace + body-path: .tbdocs/docs-report.md diff --git a/.github/workflows/tests-ci.yml b/.github/workflows/tests-ci.yml index 5c6131f08..afa549f88 100644 --- a/.github/workflows/tests-ci.yml +++ b/.github/workflows/tests-ci.yml @@ -128,39 +128,6 @@ jobs: env: TEST_DWN_URL: http://localhost:3000 - tbdocs-reporter: - runs-on: ubuntu-latest - steps: - - name: Checkout source - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - - - name: Set up Node.js - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - with: - node-version: 18 - registry-url: https://registry.npmjs.org/ - - - name: Install latest npm - run: npm install -g npm@latest - - - name: Install dependencies - run: npm ci - - - name: Build all workspace packages - run: npm run build - - - name: TBDocs Reporter - id: tbdocs-reporter-protocol - uses: TBD54566975/tbdocs@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - report_changed_scope_only: false - fail_on_error: false - entry_points: | - - file: packages/api/src/index.ts - docsReporter: api-extractor - docsGenerator: typedoc-markdown - web5-spec: runs-on: ubuntu-latest steps: