Skip to content

chore(deps): bump actions/setup-node from 3 to 4 #435

chore(deps): bump actions/setup-node from 3 to 4

chore(deps): bump actions/setup-node from 3 to 4 #435

Workflow file for this run

name: free-programming-books-lint
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- run: npm install -g free-programming-books-lint
- name: Push
if: ${{ github.event_name == 'push' }}
run: |
fpb-lint ./books/
fpb-lint ./casts/
fpb-lint ./courses/
fpb-lint ./more/
- name: Pull Request
if: ${{ always() &&
github.event_name == 'pull_request' }}
run: |
fpb-lint ./books/ &>> output.log || echo "Analyzing..."
fpb-lint ./casts/ &>> output.log || echo "Analyzing..."
fpb-lint ./courses/ &>> output.log || echo "Analyzing..."
fpb-lint ./more/ &>> output.log || echo "Analyzing..."
touch error.log
- name: Clean output
if: ${{ always() &&
github.event_name == 'pull_request' }}
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const readline = require('readline');
const file = readline.createInterface({
input: fs.createReadStream('output.log'),
output: process.stdout,
terminal: false,
});
let lastLine = '';
file.on('line', (line) => {
if (lastLine) {
fs.appendFile('error.log', lastLine, (err) => {
if (err) {
console.error(err);
}
});
}
if (line.includes('/home/runner/work/free-programming-books/')) {
lastLine = line.replace('/home/runner/work/free-programming-books/', '') + "\r\n";
} else if (line.includes('\u26a0')) {
lastLine = '\r\n\r\n';
} else if (line.includes('remark-lint')) {
lastLine = line + '\r\n';
} else {
lastLine = null;
}
});
file.on('close', () => {
if (!lastLine || lastLine === '\r\n\r\n') {
return;
}
fs.appendFile('error.log', lastLine, (err) => {
if (err) {
console.error(err);
}
});
});
- name: Upload artifact
if: ${{ always() &&
github.event_name == 'pull_request' }}
run: |
mkdir -p ./pr
echo ${{ github.event.pull_request.html_url }} > ./pr/PRurl
mv error.log ./pr/error.log
- uses: actions/upload-artifact@v3
with:
name: pr
path: pr/