ci: fix github workflows

This commit is contained in:
Daniel N 2023-09-18 12:21:02 +02:00
parent c1fec15c9e
commit e8de796738
5 changed files with 3 additions and 141 deletions

View File

@ -1,33 +0,0 @@
name: auto build data
on:
push:
branches:
- master
paths:
- data/**
jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.repository == 'ipfs/awesome-ipfs'"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 13
- name: build
run: |
npm --version
node --version
npm ci
npm run lint
npm run build
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "Rebuild" -a
- name: Push changes
if: success()
run: git push

View File

@ -7,27 +7,8 @@ on:
branches: [ master, main ]
jobs:
# Run linting and tests
build-and-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: 13
- uses: ipfs/aegir/actions/cache-node-modules@master
with:
directories: |
README.md
build: |
npm run build:readme
cache_name: readme
# aegir/actions/cache-node-modules runs build. We don't need to run it again.
- run: npm run lint
run-danger:
runs-on: ubuntu-latest
needs: build-and-lint
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
@ -40,13 +21,6 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.2
- uses: ipfs/aegir/actions/cache-node-modules@master
with:
directories: |
README.md
build: |
npm run build:readme
cache_name: readme
- name: Install and run awesome_bot
# It's okay for awesome_bot to fail (for maintainers only). Danger will post a comment on the PR (for maintainers only) if it fails.
run: |

View File

@ -2,34 +2,13 @@ const { danger, markdown, fail, warn, message } = require('danger')
const awesomeBotResults = require('./ab-results-README.md-markdown-table.json')
const githubMetadata = danger.git.fileMatch('.github/**')
const yamlData = danger.git.fileMatch('data/**')
const scripts = danger.git.fileMatch('scripts/**')
const src = danger.git.fileMatch('src/**')
const readme = danger.git.fileMatch('README.md')
if (readme.edited) {
fail('Please do not edit the README directly. It is generated from the data in the data/ directory.')
if (readme.edited && awesomeBotResults.error) {
fail(awesomeBotResults.title)
markdown(awesomeBotResults.message)
}
if (githubMetadata.edited) {
message('Changes were made within the .github folder.')
}
if (yamlData.edited) {
message('YAML data files were edited.')
/**
* Only display awesomeBot results if the data yaml used to generate the readme have been modified.
*/
if (awesomeBotResults.error) {
fail(awesomeBotResults.title)
markdown(awesomeBotResults.message)
}
}
if (scripts.edited) {
warn('Changes were made to the scripts folder.')
}
if (src.edited) {
warn('Changes were made to the src folder.')
}

View File

@ -1,30 +0,0 @@
/**
* This file assumes that awesome_bot has already been ran.
*/
const markdownTable = require('../ab-results-README.md-markdown-table.json')
const fs = require('fs').promises
const { join } = require('path')
const dir = join(__dirname, '../data')
if (markdownTable.error) {
const brokenLinks = require('../ab-results-README.md-filtered.json').map((resultsData) => resultsData.link);
(async () => {
const files = (await fs.readdir(dir)).map(file => join(dir, file))
for await (const filePath of files) {
let fileContents = await fs.readFile(filePath, 'utf8')
brokenLinks.forEach((brokenLink) => {
console.log('Searching for "' + brokenLink + '" in ' + filePath)
const regex = new RegExp(brokenLink, 'g')
if (fileContents.match(regex)) {
fileContents = fileContents.replace(regex, '')
console.log('Removed "' + brokenLink + '" from ' + filePath)
}
})
await fs.writeFile(filePath, fileContents, 'utf8')
}
})()
} else {
console.log('No errors reported by awesome_bot.')
}

View File

@ -1,28 +0,0 @@
const sort = (a, b) => {
if (a < b) return -1
if (a > b) return 1
return 0
}
const sortInv = (a, b) => -sort(a, b)
const sortAbc = (a, b) => {
a = a.toLowerCase()
b = b.toLowerCase()
return sort(a, b)
}
const slugify = (text) => text.toString()
.toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^\w-]+/g, '')
.replace(/--+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '')
module.exports = {
sort,
sortInv,
sortAbc,
slugify
}