From dbf207a670f7b7917a3a34f067dcaf7b132cb8d2 Mon Sep 17 00:00:00 2001 From: Federico Grandi Date: Wed, 23 Dec 2020 14:27:27 +0100 Subject: [PATCH] chore(docs): switch to dynamic all-contributors badge --- .github/workflows/docs.yml | 31 ------------------------------- README.md | 2 +- package.json | 1 - scripts/all-contributors-badge.ts | 24 ------------------------ 4 files changed, 1 insertion(+), 57 deletions(-) delete mode 100644 .github/workflows/docs.yml delete mode 100644 scripts/all-contributors-badge.ts diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 9ce3de1eb..000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Docs -on: - push: - branches: - - master - paths: - - .all-contributorsrc - - .github/workflows/docs.yml - workflow_dispatch: - -jobs: - contributors: - name: Update contributors badge - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - run: npm install - - - run: npm run all-contributors-badge - - - uses: EndBug/add-and-commit@v4.0.0 - with: - message: '[auto] docs: update contributors badge' - add: README.md - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 652a785ac..f22bdde9e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Add & Commit [![Public workflows that use this action.](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3DEndBug%2Fadd-and-commit%26badge%3Dtrue)](https://github.com/search?o=desc&q=EndBug+add-and-commit+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code) -[![All Contributors](https://img.shields.io/badge/all_contributors-21-orange.svg?style=flat)](#contributors-) +[![All Contributors](https://img.shields.io/github/all-contributors/EndBug/add-and-commit)](#contributors-) You can use this GitHub Action to commit changes made in your workflow run directly to your repo: for example, you use it to lint your code, update documentation, commit updated builds, etc.... diff --git a/package.json b/package.json index 2eda19713..df14602d3 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "watch": "ncc build src/main.ts --watch --out lib", "lint": "eslint --ext .ts src", "lint:fix": "eslint --ext .ts --fix src", - "all-contributors-badge": "ts-node scripts/all-contributors-badge", "changelog": "ts-node scripts/changelog.ts && npm i", "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/scripts/all-contributors-badge.ts b/scripts/all-contributors-badge.ts deleted file mode 100644 index 6036728e5..000000000 --- a/scripts/all-contributors-badge.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as fs from 'fs' -import { resolve } from 'path' - -function path(...segments: string[]) { - return resolve(__dirname, '..', ...segments) -} - -const README = fs.readFileSync(path('README.md'), { encoding: 'utf8' }), - { contributors } = JSON.parse( - fs.readFileSync(path('.all-contributorsrc'), { encoding: 'utf8' }) - ) -if (!(contributors instanceof Array)) throw new Error('Invalid config file') - -const updatedREADME = README.split('\n') - .map((line) => - line.startsWith( - '[![All Contributors](https://img.shields.io/badge/all_contributors-' - ) - ? `[![All Contributors](https://img.shields.io/badge/all_contributors-${contributors.length}-orange.svg?style=flat)](#contributors-)` - : line - ) - .join('\n') - -fs.writeFileSync(path('README.md'), updatedREADME)