Skip to content

Commit

Permalink
decouple tbdocs commenter (#323)
Browse files Browse the repository at this point in the history
* decouple tbdocs commenter

* trigger comment

* Decouple docs actions
  • Loading branch information
leordev authored and finn-tbd committed Mar 19, 2024
1 parent 2859b64 commit 4ed7308
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 33 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
@@ -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
52 changes: 52 additions & 0 deletions .github/workflows/tbdocs-commenter.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 0 additions & 33 deletions .github/workflows/tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4ed7308

Please sign in to comment.