From 5f2dc8ad7a84f34037c2649bec2efb10a3a07d2f Mon Sep 17 00:00:00 2001 From: Andrew Luca Date: Thu, 9 Jan 2020 19:08:21 +0200 Subject: [PATCH] feat: add action to generate readme.md from data.js Closes #155 --- .github/workflows/populate-readme.yml | 35 +++++++++++++++++++++++++++ package.json | 1 + scripts/populate-readme.js | 13 ++++++++++ scripts/readme-template.md | 31 ++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 .github/workflows/populate-readme.yml create mode 100644 scripts/populate-readme.js create mode 100644 scripts/readme-template.md diff --git a/.github/workflows/populate-readme.yml b/.github/workflows/populate-readme.yml new file mode 100644 index 00000000..9ef6154e --- /dev/null +++ b/.github/workflows/populate-readme.yml @@ -0,0 +1,35 @@ +name: Populate README.md from master + +on: + push: + branches: website + paths: src/data.js + +env: + CI: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 13.x + - name: Populate README.md from master + run: | + node ./scripts/populate-readme.js + git add generated-readme.md + git stash -- generated-readme.md + git checkout master + git stash pop + git reset + mv generated-readme.md readme.md + git add readme.md + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -m "chore: generate \`readme.md\`" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index cdabb3a1..c907a8d1 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "description": "What do you uses", "version": "7.7.7", "author": "Wes Bos", + "type": "module", "eslintConfig": { "extends": [ "wesbos" diff --git a/scripts/populate-readme.js b/scripts/populate-readme.js new file mode 100644 index 00000000..3a834d5c --- /dev/null +++ b/scripts/populate-readme.js @@ -0,0 +1,13 @@ +import fs from 'fs'; +import data from '../src/data.js'; + +/** @type {string} */ +const readmeTemplate = fs.readFileSync('./scripts/readme-template.md', 'utf8'); +const formatedData = data + .map(page => `* [${page.name}](${page.url}) — ${page.description}`) + .join('\r\n'); + +fs.writeFileSync( + 'generated-readme.md', + readmeTemplate.replace('###DATA_PLACEHOLDER###', formatedData) +); diff --git a/scripts/readme-template.md b/scripts/readme-template.md new file mode 100644 index 00000000..08afbcad --- /dev/null +++ b/scripts/readme-template.md @@ -0,0 +1,31 @@ +A site for this repo is currently being build. Please check out the [website](https://github.com/wesbos/awesome-uses/tree/website) branch and add yourself in there! +``` + ▄████████ ▄█ █▄ ▄████████ ▄████████ ▄██████▄ ▄▄▄▄███▄▄▄▄ ▄████████ + ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███ + ███ ███ ███ ███ ███ █▀ ███ █▀ ███ ███ ███ ███ ███ ███ █▀ + ███ ███ ███ ███ ▄███▄▄▄ ███ ███ ███ ███ ███ ███ ▄███▄▄▄ +▀███████████ ███ ███ ▀▀███▀▀▀ ▀███████████ ███ ███ ███ ███ ███ ▀▀███▀▀▀ + ███ ███ ███ ███ ███ █▄ ███ ███ ███ ███ ███ ███ ███ █▄ + ███ ███ ███ ▄█▄ ███ ███ ███ ▄█ ███ ███ ███ ███ ███ ███ ███ ███ + ███ █▀ ▀███▀███▀ ██████████ ▄████████▀ ▀██████▀ ▀█ ███ █▀ ██████████ + +███ █▄ ▄████████ ▄████████ ▄████████ +███ ███ ███ ███ ███ ███ ███ ███ +███ ███ ███ █▀ ███ █▀ ███ █▀ +███ ███ ███ ▄███▄▄▄ ███ +███ ███ ▀███████████ ▀▀███▀▀▀ ▀███████████ +███ ███ ███ ███ █▄ ███ +███ ███ ▄█ ███ ███ ███ ▄█ ███ +████████▀ ▄████████▀ ██████████ ▄████████▀ + +``` + +# Awesome Uses ![Awesome][awesome-badge] + +A list of /uses pages that detail apps and gear used by professional web developers. + +Submit your own. URL must be /uses. Link your name along with a few words that describes what you do. + +###DATA_PLACEHOLDER### + +[awesome-badge]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg \ No newline at end of file