From e7ccf7f8d831bc0968578440015dd871600d2057 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Sat, 28 Oct 2023 12:33:22 +0530 Subject: [PATCH 1/5] ci: add update-docs workflow --- .github/workflows/global-replicator.yml | 18 ++++++++ .../workflows/update-docs-on-docs-commit.yml | 42 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 .github/workflows/update-docs-on-docs-commit.yml diff --git a/.github/workflows/global-replicator.yml b/.github/workflows/global-replicator.yml index df0b23f3..b81919cb 100644 --- a/.github/workflows/global-replicator.yml +++ b/.github/workflows/global-replicator.yml @@ -179,4 +179,22 @@ jobs: committer_username: asyncapi-bot committer_email: info@asyncapi.io commit_message: "ci: update of files from global .github repo" + bot_branch_name: bot/update-files-from-global-repo + + replicate_docs_workflow: + if: startsWith(github.repository, 'asyncapi/') + name: Replicate update-docs workflow to repositories + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Replicating file + uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25 + with: + github_token: ${{ secrets.GH_TOKEN }} + patterns_to_include: .github/workflows/update-docs-on-docs-commit.yml + topics_to_include: autogenerate-docs + committer_username: asyncapi-bot + committer_email: info@asyncapi.io + commit_message: "ci: update of files from global .github repo" bot_branch_name: bot/update-files-from-global-repo \ No newline at end of file diff --git a/.github/workflows/update-docs-on-docs-commit.yml b/.github/workflows/update-docs-on-docs-commit.yml new file mode 100644 index 00000000..20663ffc --- /dev/null +++ b/.github/workflows/update-docs-on-docs-commit.yml @@ -0,0 +1,42 @@ +# This workflow is centrally managed in https://github.com/asyncapi/.github/ +# 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 + +# The given workflow is responsible for generating docs and creating PR with them when there is a commit with docs: prefix + +# This workflow will be updated in all repos with the topic autogenerate-docs + +name: 'Update generated parts of documentation on docs: commits' + +on: + push: + branches: + - master + +jobs: + docs-gen: + name: 'Generate docs and create PR' + runs-on: ubuntu-latest + # PR should be created within this GH action only if it is a docs: commit + # Otherwise it will conflict with release workflow + if: startsWith(github.event.commits[0].message, 'docs:') + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Regenerate docs + run: npm run generate:assets + - name: Create Pull Request with updated docs + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GH_TOKEN }} + commit-message: 'chore: update generated docs' + committer: asyncapi-bot + author: asyncapi-bot + title: 'chore: update generated docs' + body: 'Update of docs that are generated and were forgotten on PR level.' + branch: gen-docs-update \ No newline at end of file From a965037d42cb7c9d09477f1d4f4a4e4571b7416a Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Sun, 29 Oct 2023 14:44:04 +0530 Subject: [PATCH 2/5] chore: commit suggestion use commits instead of tags as they are not vulnerable to any bad actors activity (removal of tag, or recreating tag that points to code that sneaks out the api keys) Co-authored-by: Animesh Kumar --- .github/workflows/update-docs-on-docs-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-on-docs-commit.yml b/.github/workflows/update-docs-on-docs-commit.yml index 20663ffc..7b600a18 100644 --- a/.github/workflows/update-docs-on-docs-commit.yml +++ b/.github/workflows/update-docs-on-docs-commit.yml @@ -31,7 +31,7 @@ jobs: - name: Regenerate docs run: npm run generate:assets - name: Create Pull Request with updated docs - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # use 4.2.4 https://github.com/peter-evans/create-pull-request/releases/tag/v5.0.2 with: token: ${{ secrets.GH_TOKEN }} commit-message: 'chore: update generated docs' From aec32bf346c271b8a8a13ab9d0d45227cf127f82 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Sun, 29 Oct 2023 15:37:28 +0530 Subject: [PATCH 3/5] chore: commit suggestion Co-authored-by: Animesh Kumar --- .github/workflows/update-docs-on-docs-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-on-docs-commit.yml b/.github/workflows/update-docs-on-docs-commit.yml index 7b600a18..33c6efab 100644 --- a/.github/workflows/update-docs-on-docs-commit.yml +++ b/.github/workflows/update-docs-on-docs-commit.yml @@ -31,7 +31,7 @@ jobs: - name: Regenerate docs run: npm run generate:assets - name: Create Pull Request with updated docs - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # use 4.2.4 https://github.com/peter-evans/create-pull-request/releases/tag/v5.0.2 + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # uses 5.0.2 https://github.com/peter-evans/create-pull-request/releases/tag/v5.0.2 with: token: ${{ secrets.GH_TOKEN }} commit-message: 'chore: update generated docs' From 101da825d70899083e4a3c0a54ce3fdeaa01846f Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Wed, 1 Nov 2023 01:42:24 +0530 Subject: [PATCH 4/5] chore: rename docs commit workflow * topic changed to get-global-docs-autoupdate --- .github/workflows/global-replicator.yml | 6 +++--- ...commit.yml => update-docs-on-docs-commits.yml} | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) rename .github/workflows/{update-docs-on-docs-commit.yml => update-docs-on-docs-commits.yml} (74%) diff --git a/.github/workflows/global-replicator.yml b/.github/workflows/global-replicator.yml index b81919cb..71d78c16 100644 --- a/.github/workflows/global-replicator.yml +++ b/.github/workflows/global-replicator.yml @@ -192,9 +192,9 @@ jobs: uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25 with: github_token: ${{ secrets.GH_TOKEN }} - patterns_to_include: .github/workflows/update-docs-on-docs-commit.yml - topics_to_include: autogenerate-docs + patterns_to_include: .github/workflows/update-docs-on-docs-commits.yml + topics_to_include: get-global-docs-autoupdate committer_username: asyncapi-bot committer_email: info@asyncapi.io commit_message: "ci: update of files from global .github repo" - bot_branch_name: bot/update-files-from-global-repo \ No newline at end of file + bot_branch_name: bot/update-files-from-global-repo/${{ github.job }} \ No newline at end of file diff --git a/.github/workflows/update-docs-on-docs-commit.yml b/.github/workflows/update-docs-on-docs-commits.yml similarity index 74% rename from .github/workflows/update-docs-on-docs-commit.yml rename to .github/workflows/update-docs-on-docs-commits.yml index 33c6efab..3b3b7507 100644 --- a/.github/workflows/update-docs-on-docs-commit.yml +++ b/.github/workflows/update-docs-on-docs-commits.yml @@ -3,7 +3,7 @@ # The given workflow is responsible for generating docs and creating PR with them when there is a commit with docs: prefix -# This workflow will be updated in all repos with the topic autogenerate-docs +# This workflow will be updated in all repos with the topic get-global-docs-autoupdate name: 'Update generated parts of documentation on docs: commits' @@ -22,14 +22,19 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 - - name: Setup Node.js + - name: Check package-lock version + uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master + id: lockversion + - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: 18 + node-version: "${{ steps.lockversion.outputs.version }}" + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - name: Install dependencies run: npm ci - name: Regenerate docs - run: npm run generate:assets + run: npm run generate:assets --if-present - name: Create Pull Request with updated docs uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # uses 5.0.2 https://github.com/peter-evans/create-pull-request/releases/tag/v5.0.2 with: @@ -39,4 +44,4 @@ jobs: author: asyncapi-bot title: 'chore: update generated docs' body: 'Update of docs that are generated and were forgotten on PR level.' - branch: gen-docs-update \ No newline at end of file + branch: gen-docs-update/${{ github.job }} \ No newline at end of file From 0766c64fc41189679996de220fedccf4f76a2246 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Wed, 1 Nov 2023 01:53:05 +0530 Subject: [PATCH 5/5] feat: add failure reporting to workflow --- .github/workflows/update-docs-on-docs-commits.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-on-docs-commits.yml b/.github/workflows/update-docs-on-docs-commits.yml index 3b3b7507..b511e284 100644 --- a/.github/workflows/update-docs-on-docs-commits.yml +++ b/.github/workflows/update-docs-on-docs-commits.yml @@ -44,4 +44,14 @@ jobs: author: asyncapi-bot title: 'chore: update generated docs' body: 'Update of docs that are generated and were forgotten on PR level.' - branch: gen-docs-update/${{ github.job }} \ No newline at end of file + branch: gen-docs-update/${{ github.job }} + - name: Report workflow status to Slack + if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel + uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 #using https://github.com/8398a7/action-slack/releases/tag/v3.15.1 + with: + status: ${{ job.status }} + fields: repo,action,workflow + text: 'AsyncAPI docs generation workflow failed' + author_name: asyncapi-bot + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} \ No newline at end of file