From 415a00ea219928d6b99ae745b3b169affc592350 Mon Sep 17 00:00:00 2001 From: Chukwuebuka2 Date: Mon, 22 May 2023 21:44:38 +0100 Subject: [PATCH] UPDATE: Added github workflow for contributors --- .github/workflows/update-contributors.yml | 34 +++++++++++++++++++++++ CONTRIBUTORS.md | 6 ++++ README.md | 5 +++- update-readme.js | 21 ++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-contributors.yml create mode 100644 CONTRIBUTORS.md create mode 100644 update-readme.js diff --git a/.github/workflows/update-contributors.yml b/.github/workflows/update-contributors.yml new file mode 100644 index 0000000..17bc72c --- /dev/null +++ b/.github/workflows/update-contributors.yml @@ -0,0 +1,34 @@ +name: Update Contributors + +on: + push: + branches: + - master +jobs: + update-readme: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Set Up Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + + - name: Install Dependencies + run: npm install + + - name: Update Contributors + run: node update-readme.js + + - name: Commit Changes + run: | + git config --local user.email "" + git config --local user.name "" + git add README.md + git commit -m "Update contributors in README" + git push \ No newline at end of file diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 0000000..001a6a3 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +### List of contributors + + | Name | Image | + | ------------- | ------------------------------- | + | Advaita Saha | ![Avaita Saha](https://avatars.githubusercontent.com/u/30210770?v=4) | + | Bartick Maiti | ![Bartick Maiti](https://avatars.githubusercontent.com/u/69100224?v=4) | \ No newline at end of file diff --git a/README.md b/README.md index 3f13940..6888a06 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,7 @@ Once you have installed Node.js, you can run the following commands to install t npm install npm build npm start -``` \ No newline at end of file +``` + + + \ No newline at end of file diff --git a/update-readme.js b/update-readme.js new file mode 100644 index 0000000..b8f9551 --- /dev/null +++ b/update-readme.js @@ -0,0 +1,21 @@ +const fs = require("fs"); + +// creating a function that updates the readme automatically +function updateReadme() { + // read the contributors content + const contributorsContent = fs.readFileSync("CONTRIBUTORS.md", "utf8"); + // reading the readme content + const readmeContent = fs.readFileSync("README.md", "utf8"); + + // update the readme + const updatedReadme = readmeContent.replace( + /([\s\S]*?)/, + `\n\n${contributorsContent}\n` + ); + + // re-writing the README + fs.writeFileSync('README.md', updatedReadme); +} + +// running the function +updateReadme();