diff --git a/.github/workflows/analyze.yaml b/.github/workflows/analyze.yaml index 9610bc6..3b56918 100644 --- a/.github/workflows/analyze.yaml +++ b/.github/workflows/analyze.yaml @@ -12,7 +12,12 @@ jobs: node-version: 14 - run: npm install - id: analyze - run: npm run analyze + name: Analyze PR + run: | + npm run analyze + [ -f summary.txt ] && echo "{SKIP}={false}" >> "$GITHUB_ENV" || echo "{SKIP}={true}" >> "$GITHUB_ENV" - uses: mshick/add-pr-comment@v2 + if: ${{env.SKIP == true}} + name: Comment on PR with: message-path: ./summary.txt \ No newline at end of file diff --git a/contributors b/contributors new file mode 100644 index 0000000..1b847bf --- /dev/null +++ b/contributors @@ -0,0 +1,2 @@ +mul53 +darkpaladi \ No newline at end of file diff --git a/scripts/analyze.js b/scripts/analyze.js index 78e5203..b14a27e 100644 --- a/scripts/analyze.js +++ b/scripts/analyze.js @@ -1,6 +1,5 @@ const fs = require('fs/promises') const Mustache = require('mustache') -const fetch = require('node-fetch') const isLiquidityValid = require('./helpers/isLiquidityValid') const isNameValid = require('./helpers/isNameValid') @@ -8,16 +7,20 @@ const isSymbolValid = require('./helpers/isSymbolValid') const getNewTokenList = require('./helpers/getNewTokenList') const getCurrentTokenList = require('./helpers/getCurrentTokenList') const getNewToken = require('./helpers/getNewToken') +const getContributors = require('./helpers/getContributors') async function analyze() { const errors = [] + const contributors = await getContributors() const newTokenList = await getNewTokenList() const currentTokenList = await getCurrentTokenList() - const newToken = await getNewToken(newTokenList, currentTokenList) - if (!newToken) return + if (!newToken) { + + return + } const nameError = await isNameValid(newToken, currentTokenList) if (nameError) errors.push(nameError) @@ -34,7 +37,8 @@ async function analyze() { symbol: newToken.symbol, decimals: newToken.decimals, logoURI: newToken.logoURI, - errors: errors, + contributors: contributors.map(c => `@${c}`).join(" "), + errors, } const summary = Mustache.render( @@ -48,8 +52,12 @@ async function analyze() { ❌{{.}} {{/errors}} {{/errors.length}} + {{^errors.length}} + Token check ok: + ✅ + {{/errors.length}} ![{{name}} logo]({{{logoURI}}}) - @mul53 @darkpaladi + {{contributors}} `, view, ) diff --git a/scripts/helpers/getContributors.js b/scripts/helpers/getContributors.js new file mode 100644 index 0000000..78c5f3b --- /dev/null +++ b/scripts/helpers/getContributors.js @@ -0,0 +1,6 @@ +const fs = require('fs/promises') + +module.exports = async function getContributors() { + const contributors = await fs.readFile('./contributors', { encoding: 'utf8' }) + return contributors.split('\n') +}