Skip to content

Commit 1654555

Browse files
authored
ci: add update-docs workflow (asyncapi#258)
1 parent deb094e commit 1654555

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

.github/workflows/global-replicator.yml

+19-1
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,22 @@ jobs:
179179
committer_username: asyncapi-bot
180180
committer_email: [email protected]
181181
commit_message: "ci: update of files from global .github repo"
182-
bot_branch_name: bot/update-files-from-global-repo
182+
bot_branch_name: bot/update-files-from-global-repo
183+
184+
replicate_docs_workflow:
185+
if: startsWith(github.repository, 'asyncapi/')
186+
name: Replicate update-docs workflow to repositories
187+
runs-on: ubuntu-latest
188+
steps:
189+
- name: Checkout repository
190+
uses: actions/checkout@v4
191+
- name: Replicating file
192+
uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25
193+
with:
194+
github_token: ${{ secrets.GH_TOKEN }}
195+
patterns_to_include: .github/workflows/update-docs-on-docs-commits.yml
196+
topics_to_include: get-global-docs-autoupdate
197+
committer_username: asyncapi-bot
198+
committer_email: [email protected]
199+
commit_message: "ci: update of files from global .github repo"
200+
bot_branch_name: bot/update-files-from-global-repo/${{ github.job }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This workflow is centrally managed in https://github.com/asyncapi/.github/
2+
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo
3+
4+
# The given workflow is responsible for generating docs and creating PR with them when there is a commit with docs: prefix
5+
6+
# This workflow will be updated in all repos with the topic get-global-docs-autoupdate
7+
8+
name: 'Update generated parts of documentation on docs: commits'
9+
10+
on:
11+
push:
12+
branches:
13+
- master
14+
15+
jobs:
16+
docs-gen:
17+
name: 'Generate docs and create PR'
18+
runs-on: ubuntu-latest
19+
# PR should be created within this GH action only if it is a docs: commit
20+
# Otherwise it will conflict with release workflow
21+
if: startsWith(github.event.commits[0].message, 'docs:')
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v4
25+
- name: Check package-lock version
26+
uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master
27+
id: lockversion
28+
- name: Use Node.js
29+
uses: actions/setup-node@v3
30+
with:
31+
node-version: "${{ steps.lockversion.outputs.version }}"
32+
cache: 'npm'
33+
cache-dependency-path: '**/package-lock.json'
34+
- name: Install dependencies
35+
run: npm ci
36+
- name: Regenerate docs
37+
run: npm run generate:assets --if-present
38+
- name: Create Pull Request with updated docs
39+
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # uses 5.0.2 https://github.com/peter-evans/create-pull-request/releases/tag/v5.0.2
40+
with:
41+
token: ${{ secrets.GH_TOKEN }}
42+
commit-message: 'chore: update generated docs'
43+
committer: asyncapi-bot <[email protected]>
44+
author: asyncapi-bot <[email protected]>
45+
title: 'chore: update generated docs'
46+
body: 'Update of docs that are generated and were forgotten on PR level.'
47+
branch: gen-docs-update/${{ github.job }}
48+
- name: Report workflow status to Slack
49+
if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
50+
uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 #using https://github.com/8398a7/action-slack/releases/tag/v3.15.1
51+
with:
52+
status: ${{ job.status }}
53+
fields: repo,action,workflow
54+
text: 'AsyncAPI docs generation workflow failed'
55+
author_name: asyncapi-bot
56+
env:
57+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}

0 commit comments

Comments
 (0)