Tucker McKnight
Add an optional "artifactSteps" category This field in the config allows you to specify a list of build steps. These build steps will run on every branch in the repo, then copy a directory into the resulting _site directory for that given branch.
82
82
if (typeof repoConfig.artifactSteps !== 'undefined') {
// make a temp directory for things to run in
const tempDirName = `temp_${Math.floor(Math.random() * 10000).toString()}`
const tempDir = `${directories.output}${reposPath}${tempDirName}`
const tempDirRepoPath = `${tempDir}/${eleventyConfig.getFilter("slugify")(repoName)}`
const mkdirresult = await exec(`mkdir ${tempDir}`)
await exec(`git clone -s ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}.git ${tempDirRepoPath}`)
Promise.all(repoConfig.branchesToPull.map(async (branch) => {
await exec(`(cd ${tempDirRepoPath} && git checkout ${branch})`)
return Promise.all(repoConfig.artifactSteps.map(async (artifactStep) => {
// Run the command for each step in each branch
await exec(`(cd ${tempDirRepoPath} && ${artifactStep.command})`)
// Copy the specified folders from the "from" to the "to" dir
return exec(`cp -r ${tempDirRepoPath}/${artifactStep.copyFrom} ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branch)}/${artifactStep.copyTo}`)
}))
})).then(async () => {
// delete the temp dirs
await exec(`rm -r ${tempDir}`)
})
}
11
11
"artifactSteps": {
"items": {
"additionalProperties": false,
"properties": {
"command": {
"type": "string"
},
"copyFrom": {
"type": "string"
},
"copyTo": {
"type": "string"
}
},
"required": [
"command",
"copyFrom",
"copyTo"
],
"type": "object"
},
"type": "array"
},
59
59
"artifactSteps": {
"items": {
"additionalProperties": false,
"properties": {
"command": {
"type": "string"
},
"copyFrom": {
"type": "string"
},
"copyTo": {
"type": "string"
}
},
"required": [
"command",
"copyFrom",
"copyTo"
],
"type": "object"
},
"type": "array"
},
71
}
71
},
artifactSteps?: {
command: string,
copyFrom: string,
copyTo: string,
}[]
153
}
153
},
artifactSteps?: {
command: string,
copyFrom: string,
copyTo: string,
}[]