Action to merge changes made by script back into repo #45289
-
Select Topic AreaQuestion BodyI currently have an action setup that will (1) checkout my repo (2) install node and dependencies (3) run a script that takes my directories/files and creates a JSON file with all their file paths. I am needing this action to take this JSON file and merge it back into my repo so that I may use the GitHub API to retrieve it. My code is as follows. Everything runs okay but the new workflow: name: build-toc-json
run-name: ${{ github.actor }} is building the table of contents JSON
on: push
jobs:
build-toc-json:
runs-on: macos-11
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install node-dir
- run: node buildNav script that runs when I use const fs = require("fs");
const dir = require('node-dir');
// display contents of files in this directory
dir.readFiles("src/chapters",
// get content of files
function(err, content, next) {
if (err) throw err;
next();
},
// get file names
function(err, files){
if (err) throw err;
// if `dist` folder does not exist create it
try {
fs.readdirSync("api");
} catch (e) {
fs.mkdirSync("api");
}
// map through file names and remove `dist/`
let paths = files.map((path) => {
let replaced = path.replace("dist", "");
return replaced;
});
// create JSON file of our navigation
fs.writeFile("api/toc.json", JSON.stringify(paths), err => {
if (err) return console.log(err);
});
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This action is probably the easiest way to achieve that: https://github.com/stefanzweifel/git-auto-commit-action |
Beta Was this translation helpful? Give feedback.
This action is probably the easiest way to achieve that: https://github.com/stefanzweifel/git-auto-commit-action