Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /**
* GitHub CI Configurator
*
* Generates GitHub Actions workflow files for Hugo site builds.
*/
import path from 'path';
import fs from 'fs-extra';
/**
* GitHub Actions CI Configurator
*/
export class GithubCIConfigurator {
getName() {
return 'GitHub Actions';
}
async writeWorkflow(destinationPath, options) {
const hugoVersion = options.hugoVersion || '0.81.0';
const baseUrlArg = options.overrideBaseURL ? `--baseURL ${options.overrideBaseURL}` : '';
const yaml = `name: Hugo Build and Deploy
on:
push:
branches:
- ${options.branch}
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '${hugoVersion}'
extended: true
- name: Build
run: hugo --minify ${baseUrlArg}
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: \${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
`;
await fs.ensureDir(path.join(destinationPath, '.github', 'workflows'));
await fs.writeFile(path.join(destinationPath, '.github', 'workflows', 'hugo-build.yml'), yaml, 'utf-8');
}
}
|