From b975a704ebc9e75db14db6744aa590dfd7a69f0f Mon Sep 17 00:00:00 2001 From: Prince Rajpoot Date: Wed, 25 Oct 2023 00:31:26 +0530 Subject: [PATCH 1/8] adding tool preview workflow --- .github/workflows/tools-preview.yml | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/tools-preview.yml diff --git a/.github/workflows/tools-preview.yml b/.github/workflows/tools-preview.yml new file mode 100644 index 000000000000..5b3dfce17edb --- /dev/null +++ b/.github/workflows/tools-preview.yml @@ -0,0 +1,33 @@ +name: Tools preview on PR level + +on: + workflow_dispatch: + +jobs: + suggestChanges: + if: github.repository == 'asyncapi/website' + runs-on: ubuntu-latest + steps: + - name: Checkout PR + uses: actions/checkout@v3 + + - name: Setup Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Install dependencies + run: npm install + + - name: Regenerate + run: npm run generate:tools + + - name: Suggest changes + run: | + git diff > changes.diff + if [[ -s changes.diff ]]; then + # Adding suggestions with changes + gh pr review ${{ github.event.pull_request.number }} --comment -b "Changes based on the regeneration: \n\n\`\`\`diff\n$(cat changes.diff)\n\`\`\`" + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From fa3e13c489ee386fcb6df3733318abe32ccdc65b Mon Sep 17 00:00:00 2001 From: Prince Rajpoot Date: Thu, 26 Oct 2023 02:32:45 +0530 Subject: [PATCH 2/8] update workflow --- .github/workflows/tools-preview.yml | 49 +++++++++++++++++------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tools-preview.yml b/.github/workflows/tools-preview.yml index 5b3dfce17edb..52785b7d3bbe 100644 --- a/.github/workflows/tools-preview.yml +++ b/.github/workflows/tools-preview.yml @@ -2,32 +2,41 @@ name: Tools preview on PR level on: workflow_dispatch: + pull_request: + branches: + - master jobs: - suggestChanges: + regenerateTools: if: github.repository == 'asyncapi/website' + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + name: Regenerate tools.json runs-on: ubuntu-latest steps: - - name: Checkout PR - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} - - name: Setup Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x - - name: Install dependencies - run: npm install + - name: Install dependencies + run: npm install - - name: Regenerate - run: npm run generate:tools + - name: Regenerate + run: npm run generate:tools - - name: Suggest changes - run: | - git diff > changes.diff - if [[ -s changes.diff ]]; then - # Adding suggestions with changes - gh pr review ${{ github.event.pull_request.number }} --comment -b "Changes based on the regeneration: \n\n\`\`\`diff\n$(cat changes.diff)\n\`\`\`" - fi - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Pull Request with new tools.json version + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GH_TOKEN }} + commit-message: 'chore: update tools.json' + committer: asyncapi-bot + author: asyncapi-bot + title: 'chore: update tools.json' + branch: update-tools/${{ github.run_number }} + base: ${{ github.head_ref }} From 9a2e84f89354697a8d2ef689f536b12261fb0b40 Mon Sep 17 00:00:00 2001 From: Prince Rajpoot Date: Thu, 26 Oct 2023 02:40:23 +0530 Subject: [PATCH 3/8] minor changes --- .github/workflows/tools-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tools-preview.yml b/.github/workflows/tools-preview.yml index 52785b7d3bbe..0ffaa4b7fea2 100644 --- a/.github/workflows/tools-preview.yml +++ b/.github/workflows/tools-preview.yml @@ -17,7 +17,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 with: - ref: ${{ github.head_ref }} + ref: ${{ github.event_name == 'pull_request' && github.head_ref || '' }} - name: Use Node.js uses: actions/setup-node@v3 From 95c1ece9d75dd80687b1da4ac4ab1ac8ea222929 Mon Sep 17 00:00:00 2001 From: Prince Rajpoot Date: Mon, 30 Oct 2023 01:03:08 +0530 Subject: [PATCH 4/8] removed recently added workflow --- .github/workflows/tools-preview.yml | 42 ----------------------------- 1 file changed, 42 deletions(-) delete mode 100644 .github/workflows/tools-preview.yml diff --git a/.github/workflows/tools-preview.yml b/.github/workflows/tools-preview.yml deleted file mode 100644 index 0ffaa4b7fea2..000000000000 --- a/.github/workflows/tools-preview.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Tools preview on PR level - -on: - workflow_dispatch: - pull_request: - branches: - - master - -jobs: - regenerateTools: - if: github.repository == 'asyncapi/website' - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - name: Regenerate tools.json - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event_name == 'pull_request' && github.head_ref || '' }} - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 16.x - - - name: Install dependencies - run: npm install - - - name: Regenerate - run: npm run generate:tools - - - name: Create Pull Request with new tools.json version - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GH_TOKEN }} - commit-message: 'chore: update tools.json' - committer: asyncapi-bot - author: asyncapi-bot - title: 'chore: update tools.json' - branch: update-tools/${{ github.run_number }} - base: ${{ github.head_ref }} From c71b27b95d05520b2a7620ebe9480e1fb5023fa1 Mon Sep 17 00:00:00 2001 From: Prince Rajpoot Date: Mon, 30 Oct 2023 01:10:51 +0530 Subject: [PATCH 5/8] added manual tool regeneration --- scripts/build-tools.js | 52 +++++++++++++++++++++++++++++++----------- scripts/index.js | 2 ++ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 363e34188161..d1f49ddd23f9 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -6,19 +6,45 @@ const manualTools = require('../config/tools-manual.json') const fs = require('fs'); const { resolve } = require('path'); +const combineAutomatedAndManualTools = async (automatedTools) => { + try { + await combineTools(automatedTools, manualTools); + } catch (err) { + console.log("Error while combining tools:", err); + throw err; + } +}; + const buildTools = async () => { - try { - let githubExtractData = await getData(); - let automatedTools = await convertTools(githubExtractData); - fs.writeFileSync( - resolve(__dirname, '../config', 'tools-automated.json'), - JSON.stringify(automatedTools, null, ' ') - ); - await combineTools(automatedTools, manualTools); - } catch (err) { - console.log(err); - throw err - } + try { + let githubExtractData = await getData(); + let automatedTools = await convertTools(githubExtractData); + fs.writeFileSync( + resolve(__dirname, '../config', 'tools-automated.json'), + JSON.stringify(automatedTools, null, ' ') + ); + await combineAutomatedAndManualTools(automatedTools); + } catch (err) { + console.log(err); + throw err; + } }; -buildTools(); \ No newline at end of file +const buildToolsManual = async () => { + try { + const automatedTools = require('../config/tools-automated.json'); + await combineAutomatedAndManualTools(automatedTools); + } catch (err) { + console.log(err); + throw err; + } +}; + +if (require.main === module) { + buildTools(); +} + +module.exports = { + buildTools, + buildToolsManual +}; \ No newline at end of file diff --git a/scripts/index.js b/scripts/index.js index 0634672c55f2..57a5b01f1ab3 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -1,6 +1,7 @@ const rssFeed = require('./build-rss'); const buildPostList = require('./build-post-list'); const buildCaseStudiesList = require('./casestudies'); +const { buildToolsManual } = require('./build-tools'); async function start() { await buildPostList(); @@ -17,6 +18,7 @@ async function start() { 'jobs/rss.xml' ); await buildCaseStudiesList(); + await buildToolsManual(); } start(); \ No newline at end of file From ee9e1432914b7b64e973cafe2e9d85d6dcc267af Mon Sep 17 00:00:00 2001 From: Prince Rajpoot Date: Mon, 30 Oct 2023 01:19:20 +0530 Subject: [PATCH 6/8] lint fix --- scripts/build-tools.js | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index d1f49ddd23f9..cd2769f64ac8 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -7,44 +7,44 @@ const fs = require('fs'); const { resolve } = require('path'); const combineAutomatedAndManualTools = async (automatedTools) => { - try { - await combineTools(automatedTools, manualTools); - } catch (err) { - console.log("Error while combining tools:", err); - throw err; - } + try { + await combineTools(automatedTools, manualTools); + } catch (err) { + console.log("Error while combining tools:", err); + throw err; + } }; const buildTools = async () => { - try { - let githubExtractData = await getData(); - let automatedTools = await convertTools(githubExtractData); - fs.writeFileSync( - resolve(__dirname, '../config', 'tools-automated.json'), - JSON.stringify(automatedTools, null, ' ') - ); - await combineAutomatedAndManualTools(automatedTools); - } catch (err) { - console.log(err); - throw err; - } + try { + let githubExtractData = await getData(); + let automatedTools = await convertTools(githubExtractData); + fs.writeFileSync( + resolve(__dirname, '../config', 'tools-automated.json'), + JSON.stringify(automatedTools, null, ' ') + ); + await combineAutomatedAndManualTools(automatedTools); + } catch (err) { + console.log(err); + throw err; + } }; const buildToolsManual = async () => { - try { - const automatedTools = require('../config/tools-automated.json'); - await combineAutomatedAndManualTools(automatedTools); - } catch (err) { - console.log(err); - throw err; - } + try { + const automatedTools = require('../config/tools-automated.json'); + await combineAutomatedAndManualTools(automatedTools); + } catch (err) { + console.log(err); + throw err; + } }; if (require.main === module) { - buildTools(); + buildTools(); } module.exports = { - buildTools, - buildToolsManual + buildTools, + buildToolsManual }; \ No newline at end of file From 8ce6f8159456493d692885e7a302120e1db9f602 Mon Sep 17 00:00:00 2001 From: Prince Rajpoot Date: Mon, 30 Oct 2023 01:25:00 +0530 Subject: [PATCH 7/8] lint fix --- scripts/build-tools.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index cd2769f64ac8..0d9be77352c8 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -20,13 +20,13 @@ const buildTools = async () => { let githubExtractData = await getData(); let automatedTools = await convertTools(githubExtractData); fs.writeFileSync( - resolve(__dirname, '../config', 'tools-automated.json'), - JSON.stringify(automatedTools, null, ' ') + resolve(__dirname, '../config', 'tools-automated.json'), + JSON.stringify(automatedTools, null, ' ') ); await combineAutomatedAndManualTools(automatedTools); } catch (err) { console.log(err); - throw err; + throw err } }; From f0fbfb76542e27943c2cfc6ee5cc1f54e8fe1b75 Mon Sep 17 00:00:00 2001 From: Prince Rajpoot Date: Mon, 30 Oct 2023 20:44:06 +0530 Subject: [PATCH 8/8] adding a backup plan when brain pulls a 404 Not Found --- scripts/build-tools.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 0d9be77352c8..94b3170e056d 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -40,6 +40,7 @@ const buildToolsManual = async () => { } }; +// Default action when triggered from package.json or run standalone. if (require.main === module) { buildTools(); }